GithubHelp home page GithubHelp logo

fboender / ansible-cmdb Goto Github PK

View Code? Open in Web Editor NEW
2.3K 147.0 464.0 1.45 MB

Generate host overview from ansible fact gathering output

License: GNU General Public License v3.0

Python 58.45% Smarty 2.20% HTML 33.29% Shell 0.27% NewLisp 3.04% CSS 1.30% DIGITAL Command Language 0.86% Roff 0.59%
ansible cmdb inventory overview frontend

ansible-cmdb's Introduction

Ansible Configuration Management Database

Status: Stable Build Status Activity: Active development License: GPLv3

About

Ansible-cmdb takes the output of Ansible's fact gathering and converts it into a static HTML overview page (and other things) containing system configuration information.

It supports multiple types of output (html, csv, sql, etc) and extending information gathered by Ansible with custom data. For each host it also shows the groups, host variables, custom variables and machine-local facts.

HTML example output.

Features

(Not all features are supported by all templates)

  • Multiple formats / templates:
    • Fancy HTML (--template html_fancy), as seen in the screenshots above.
    • Fancy HTML Split (--template html_fancy_split), with each host's details in a separate file (for large number of hosts).
    • CSV (--template csv), the trustworthy and flexible comma-separated format.
    • JSON (--template json), a dump of all facts in JSON format.
    • Markdown (--template markdown), useful for copy-pasting into Wiki's and such.
    • Markdown Split (--template markdown_split), with each host's details in a seperate file (for large number of hosts).
    • SQL (--template sql), for importing host facts into a (My)SQL database.
    • Plain Text table (--template txt_table), for the console gurus.
    • and of course, any custom template you're willing to make.
  • Host overview and detailed host information.
  • Host and group variables.
  • Gathered host facts and manual custom facts.
  • Adding and extending facts of existing hosts and manually adding entirely new hosts.
  • Custom columns

Getting started

Links to the full documentation can be found below, but here's a rough indication of how Ansible-cmdb works to give you an idea:

  1. Install Ansible-cmdb from source, a release package or through pip: pip install ansible-cmdb.

  2. Fetch your host's facts through ansible:

     $ mkdir out
     $ ansible -m setup --tree out/ all
    
  3. Generate the CMDB HTML with Ansible-cmdb:

     $ ansible-cmdb out/ > overview.html
    
  4. Open overview.html in your browser.

That's it! Please do read the full documentation on usage, as there are some caveats to how you can use the generated HTML.

Documentation

All documentation can be viewed at readthedocs.io.

License

Ansible-cmdb is licensed under the GPLv3:

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For the full license, see the LICENSE file.

ansible-cmdb's People

Contributors

alexbarton avatar benkonrath avatar bobuss avatar dglinder avatar fboender avatar freeseacher avatar keepwatch avatar mdmallardi avatar michaelwhitford avatar mkosmach avatar mkubenka avatar muffl0n avatar n2aws avatar nymous avatar randyr505 avatar ypid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-cmdb's Issues

TypeError: unsupported operand type(s) for /

I'm getting this error with the latest code from the repo. This is the first time I've tried generating a report for this data and, from the error, I can't tell what's causing this issue. I'm getting a similar error with yesterday's code, which also says "Error parsing: hosts: No JSON object could be decoded" before the traceback.

Traceback (most recent call last):
  File "/usr/local/bin/ansible-cmdb", line 310, in <module>
    sys.stdout.write(mytemplate.render(hosts=ansible.hosts, **params))
  File "/usr/lib64/python2.6/site-packages/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib64/python2.6/site-packages/mako/runtime.py", line 803, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib64/python2.6/site-packages/mako/runtime.py", line 835, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib64/python2.6/site-packages/mako/runtime.py", line 860, in _exec_template
    callable_(context, *args, **kwargs)
  File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 139, in render_body
  File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 39, in col_mem
  File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 313, in render_col_mem
TypeError: unsupported operand type(s) for /: 'unicode' and 'float'

UnicodeDecodeError while unicode character in hosts comment

Exception thrown after put some chinese characters as host comment in my hosts file :

ansible-cmdb -i /home/ansible/hosts -d out/ > index.html
data_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data
tpl_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/tpl
static_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/static
Params
------------------------------------------------------------
{'columns': None,
 'data_dir': '/usr/lib/ansible-cmdb/ansiblecmdb/data',
 'lib_dir': '/usr/lib/ansible-cmdb/ansiblecmdb/data',
 'local_js': '1',
 'version': '1.9'}
Hosts
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/bin/ansible-cmdb", line 91, in <module>
    sys.stdout.write(mytemplate.render(hosts=ansible.hosts, **params).encode('utf-8'))
  File "/usr/lib/ansible-cmdb/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 803, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 835, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 860, in _exec_template
    callable_(context, *args, **kwargs)
  File "_usr_lib_ansible_cmdb_ansiblecmdb_data_tpl_html_fancy_tpl", line 212, in render_body
  File "_usr_lib_ansible_cmdb_ansiblecmdb_data_tpl_html_fancy_tpl", line 50, in col_comment
  File "_usr_lib_ansible_cmdb_ansiblecmdb_data_tpl_html_fancy_tpl", line 650, in render_col_comment
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)

Add documentation for make release

Dependencies on Ubuntu 12.02 are:

  • git
  • make
  • python-markdown
  • zip
  • fakeroot
  • alien

A variable REL_VERSION has to be inserted into the Makefile with an arbitrary value?

Am I missing something?

Error when reading dynamic inventory

I have a pretty large dynamic inventory file in JSON that contains lots of groups and variables.

When I added that to ansible-cmdb via the -i option, I get the following error:

Reading host facts from out/u40.r2.dc.drivescale.com
Traceback (most recent call last):
  File "/usr/local/bin/ansible-cmdb", line 96, in <module>
    ansible = ansiblecmdb.Ansible(args, options.inventory, options.fact_cache, debug=options.debug)
  File "/usr/local/lib/ansible-cmdb/ansiblecmdb/ansible.py", line 39, in __init__
    self._handle_inventory(self.inventory_path)
  File "/usr/local/lib/ansible-cmdb/ansiblecmdb/ansible.py", line 62, in _handle_inventory
    self._handle_inventory(os.path.join(inventory_path, fname))
  File "/usr/local/lib/ansible-cmdb/ansiblecmdb/ansible.py", line 55, in _handle_inventory
    self._parse_dyn_inventory(inventory_path)
  File "/usr/local/lib/ansible-cmdb/ansiblecmdb/ansible.py", line 168, in _parse_dyn_inventory
    dyninv_parser = parser.DynInvParser(stdout.decode('utf8'))
  File "/usr/local/lib/ansible-cmdb/ansiblecmdb/parser.py", line 381, in __init__
    self._parse_group(k, v)
  File "/usr/local/lib/ansible-cmdb/ansiblecmdb/parser.py", line 404, in _parse_group
    self._get_host(hostname)['hostvars'][var_key] = var_val
UnboundLocalError: local variable 'hostname' referenced before assignment

I will email you the file it was processing when this occurred.

It is entirely possible that the way I generate my dynamic inventory is causing this problem, although Ansible has been happily using it for months.

OpenBSD hosts have missing informtion

OpenBSD hosts are missing the following information:

Host overview

  • Virtualisation (not available in facts)
  • Software architecture
  • Nr of (virtual) CPUs (semi-available in ansible_processor or ansible_processor_count key)
  • Memory usage (available in ansible_memfree_mb and ansible_memtotal_mb keys)
  • Swap usage (available in ansible_swapfree_mb and ansible_swaptotal_mb keys)
  • Disk usage (not available?)

Host details: Network

  • Networking table overview missing data

uploading to PyPI

Thank you for creating great tool!

But why don't you upload to PyPI? From PyPI, we can install using widely used python package manager pip.

I would appreciate it if you could think with this matter.

KeyError: 'size_total'

I have a new error when trying to render a new report with the current trunk code:

Traceback (most recent call last):
  File "/usr/local/bin/ansible-cmdb", line 315, in <module>
    sys.stdout.write(mytemplate.render(hosts=ansible.hosts, **params))
  File "/usr/lib64/python2.6/site-packages/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib64/python2.6/site-packages/mako/runtime.py", line 803, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib64/python2.6/site-packages/mako/runtime.py", line 835, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib64/python2.6/site-packages/mako/runtime.py", line 860, in _exec_template
    callable_(context, *args, **kwargs)
  File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 139, in render_body
  File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 35, in col_disk_usage
  File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 461, in render_col_disk_usage
KeyError: 'size_total'

When I grep the size_total values from the facts files, I don't see any issues other than a couple of hosts with values of zero. Let me know what info you may need to troubleshoot this issue.

Debian 7 : The reported error was: float() argument must be a string or a number

Getting an error while trying to generate a report for any number of servers.
Same command is working on OSX without any issue.


ansible-cmdb -d out/
data_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data
tpl_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/tpl
static_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/static
Parsing fact dir: out/
Reading host facts from out/test.server.com
template file = /usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl
Template params: {'lib_dir': '/usr/lib/ansible-cmdb/ansiblecmdb/data', 'version': '1.11', 'data_dir': '/usr/lib/ansible-cmdb/ansiblecmdb/data', 'log': <logging.RootLogger object at 0x2163210>, 'columns': None}
Rendering host overview for test.server.com


Traceback (most recent call last):
  File "/usr/bin/ansible-cmdb", line 108, in <module>
    out = mytemplate.render(hosts=ansible.hosts, **params)
  File "/usr/lib/ansible-cmdb/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 803, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 835, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 860, in _exec_template
    callable_(context, *args, **kwargs)
  File "/usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl", line 487, in render_body
    <td>${col["func"](host)}</td>
  File "/usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl", line 0, in col_mem_usage

  File "/usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl", line 106, in render_col_mem_usage
    <span style="display:none">${'%f' % (float(i["nocache"]["used"]) / i["real"]["total"])}</span>
TypeError: float() argument must be a string or a number

Whoops, it looks like something went wrong while rendering the template.

The reported error was: float() argument must be a string or a number

The output is probably not correct.
You can report a bug on the issue tracker:

  https://github.com/fboender/ansible-cmdb/issues

Please include the debugging output (-d switch) in the report!

Additional infos

cat /etc/debian_version
7.9

ansible-cmdb --version
ansible-cmdb v1.11

ansible --version
ansible 2.1.0
  configured module search path = library/

comparing hosts side-by-side

feature request:

  • comparing 2+ servers side-by-side and highlight difference (nice compliance feature... i think)
  • export/output markdown

ZeroDivisionError when there are no partitions of disk

I'm trying to add in cmdb overview Citrix xenserver, Citrix xenserver by default has mounted iso

/opt/xensource/packages/iso/XenCenter.iso
56M 56M 0 100% /var/xen/xc-install

in ansible facts gathered it shows under ansible_mounts as

        {
            "device": "/opt/xensource/packages/iso/XenCenter.iso",.
            "fstype": "iso9660",.
            "mount": "/var/xen/xc-install",.
            "options": "ro,loop=/dev/loop0",.
            "size_available": 0,.
            "size_total": 53665792,.
            "uuid": "NA"
        },.

It's not the only one mount point which has size_available 0.

ansible-cmdb out/ > cmdb/overview.html

Traceback (most recent call last):
File "/usr/local/bin/ansible-cmdb", line 134, in
sys.stdout.write(mytemplate.render(hosts=ansible.hosts))
File "/usr/lib/python2.7/site-packages/mako/template.py", line 443, in render
return runtime.render(self, self.callable, args, data)
File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 783, in _render
**kwargs_for_callable(callable, data))
File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 815, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 841, in exec_template
callable
(context, _args, *_kwargs)
File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 184, in render_body
File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 36, in col_disk_usage
File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 607, in render_col_disk_usage
ZeroDivisionError: float division by zero

ansible-cmdb fails on certain host definitions.

I was hoping to use ansible-cmdb to get a visualization of my corporate environment, with the custom variables we use. However, when I try and use ansible-cmdb with our /etc/ansible/hosts inventory file, it bombs out pretty spectacularly.

$ wc -l /etc/ansible/hosts
1673 /etc/ansible/hosts

$ ansible-cmdb out/ -i /etc/ansible/hosts > cmdb.html
Traceback (most recent call last):
File "/usr/bin/ansible-cmdb", line 454, in
ansible = Ansible(args, options.inventory, options.fact_cache, debug=options.debug)
File "/usr/bin/ansible-cmdb", line 352, in init
self.parse_hosts_inventory(self.hosts_path)
File "/usr/bin/ansible-cmdb", line 373, in parse_hosts_inventory
hosts_parser = AnsibleHostsParser(hosts_contents)
File "/usr/bin/ansible-cmdb", line 66, in init
for hostname in self.get_distinct_hostnames():
File "/usr/bin/ansible-cmdb", line 206, in get_distinct_hostnames
hostnames.extend(self.group_get_hostnames(section['name']))
File "/usr/bin/ansible-cmdb", line 271, in group_get_hostnames
hostnames.extend(self.expand_hostdef(entry['name']))
File "/usr/bin/ansible-cmdb", line 314, in expand_hostdef
start, end = pattern.split(':')
ValueError: too many values to unpack

Any help on this would be appreciated. Thanks.

Ignore hidden dotfiles

Just noting this in case anyone else gets this issue.
If you are running on a MAC and have a .DS_STORE file in the output folder you will get the following error:

UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 3131: invalid start byte

The solution is to delete these files first.
Maybe ansible-cmdb could have an option to ignore files such as dotfiles.
Or maybe use http://asepsis.binaryage.com/ to stop creating them? - Not tried it yet but might be the solution?

Remove external dependencies

When hosting the generated output on an internal system, access to internet resources like datatables.net or jquery ist not always possible or preferred.

The resources should be included in the program itself or there should be a option to use the resources locally.

inventory files with groups of groups causes an error

If you have groups of groups, it will throw an error.

[haproxy:children]
lb

[lb:children]
lb-prod
lb-dev

[lb-prod]
lb1-prod
lb2-prod

[lb-dev]
lb1-dev
lb2-dev

when running ansible-cmdb with the -i flag, it will error on the haproxy:children section, with:

$ ansible-cmdb -i hosts/default out/ > output.html
Traceback (most recent call last):
File "/usr/bin/ansible-cmdb", line 290, in
ansible = Ansible(args, options.inventory)
File "/usr/bin/ansible-cmdb", line 29, in init
self.parse_hosts(self.hosts_file)
File "/usr/bin/ansible-cmdb", line 110, in parse_hosts
for hostname in normal_groups[apply_group_name]:
KeyError: 'lb'

Error for hosts not in a group

Hosts that are not in a group cause an error like this:

Traceback (most recent call last):
  File "/usr/local/bin/ansible-cmdb", line 301, in <module>
    ansible = Ansible(args, options.inventory)
  File "/usr/local/bin/ansible-cmdb", line 29, in __init__
    self.parse_hosts(self.hosts_file)
  File "/usr/local/bin/ansible-cmdb", line 94, in parse_hosts
    raw_groups[cur_group_type].setdefault(cur_group_name, []).append(line)
KeyError: None

AttributeError: 'list' object has no attribute 'items'

Running ansible-cmdb reports/ >report.html results in the following error here:

$ ansible all_managed -m setup --tree reports/ >/dev/null
$ ansible-cmdb reports/ >report.html
Traceback (most recent call last):
  File "/usr/local/bin/ansible-cmdb", line 632, in <module>
    sys.stdout.write(mytemplate.render(hosts=ansible.hosts, **params))
  File "/usr/local/Cellar/ansible-cmdb/1.6/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/local/Cellar/ansible-cmdb/1.6/mako/runtime.py", line 803, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/local/Cellar/ansible-cmdb/1.6/mako/runtime.py", line 835, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/local/Cellar/ansible-cmdb/1.6/mako/runtime.py", line 860, in _exec_template
    callable_(context, *args, **kwargs)
  File "_usr_local_Cellar_ansible_cmdb_1_6_html_fancy_tpl", line 277, in render_body
  File "_usr_local_Cellar_ansible_cmdb_1_6_html_fancy_tpl", line 30, in r_dict
  File "_usr_local_Cellar_ansible_cmdb_1_6_html_fancy_tpl", line 526, in render_r_dict
AttributeError: 'list' object has no attribute 'items'
make: *** [report.html] Error 1

How can I help to debug this?

Question: display of facter facts?

I have facter installed on most of my servers, and have a custom/local facter fact executable as well.

Ansible's setup module calls facter, and the resulting output of ansible -m setup includes my facter info with my custom fact.

In the out directory I create prior to invoking ansible-cmdb, the JSON in the files there includes both the standard and my custom facter_ facts.

AFAICT, ansible-cmdb isn't displaying these facts.

What can change/modify in order to include one/some/all of these additional facts?

failure parsing complex variables in inventory file

Using this inventory file

Specifically the variable on line 84

  • openshift_master_identity_providers=[{'name': 'my_ldap_provider', 'challenge': 'true', 'login': 'true', 'kind': 'LDAPPasswordIdentityProvider', 'attributes': {'id': ['dn'], 'email': ['mail'], 'name': ['cn'], 'preferredUsername': ['uid']}, 'bindDN': '', 'bindPassword': '', 'ca': '', 'insecure': 'true', 'url': 'ldap://ldap.example.com:389/ou=people,o=example.com?uid'}]

And running like this

  •  ansible-cmdb --inventory=hosts-test --debug -f fact-cache/ > cmdb/overview2.html

Produces this error

 ansible-cmdb --inventory=hosts-test --debug -f fact-cache/ > cmdb/overview2.html
/usr/lib/python2.6/site-packages/pygments/plugin.py:39: UserWarning: Module mako was already imported from /usr/lib/ansible-cmdb/mako/__init__.py, but /usr/lib/python2.6/site-packages is being added to sys.path
  import pkg_resources
  data_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data
  tpl_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/tpl
  static_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/static
  Parsing fact dir: fact-cache/
  Reading host facts from fact-cache/ose-ha-etcd-02.example.com
  Reading host facts from fact-cache/ose-ha-master-03.example.com
  Reading host facts from fact-cache/ose-ha-etcd-03.example.com
  Reading host facts from fact-cache/ose-master-01.example.com
  Reading host facts from fact-cache/ose-ha-node-06.example.com
  Reading host facts from fact-cache/ose-ha-node-01.example.com
  Reading host facts from fact-cache/ose-ha-node-03.example.com
  Reading host facts from fact-cache/ose-node-02.example.com
  Reading host facts from fact-cache/ose-ha-node-04.example.com
  Reading host facts from fact-cache/ose-node-03.example.com
  Reading host facts from fact-cache/ose-ha-etcd-01.example.com
  Reading host facts from fact-cache/ose-ha-lb-01.example.com
  Reading host facts from fact-cache/ose-ha-node-02.example.com
  Reading host facts from fact-cache/ose-ha-node-05.example.com
  Reading host facts from fact-cache/ose-node-01.example.com
  Reading host facts from fact-cache/ose-ha-master-02.example.com
  Reading host facts from fact-cache/ose-ha-master-01.example.com
  Traceback (most recent call last):
        File "/usr/bin/ansible-cmdb", line 82, in <module>
            ansible = ansiblecmdb.Ansible(args, options.inventory, options.fact_cache, debug=options.debug)
          File "/usr/lib/ansible-cmdb/ansiblecmdb/ansible.py", line 39, in __init__
            self._handle_inventory(self.inventory_path)
          File "/usr/lib/ansible-cmdb/ansiblecmdb/ansible.py", line 58, in _handle_inventory
            self._parse_hosts_inventory(inventory_path)
          File "/usr/lib/ansible-cmdb/ansiblecmdb/ansible.py", line 85, in _parse_hosts_inventory
            hosts_parser = parser.HostsParser(hosts_contents)
          File "/usr/lib/ansible-cmdb/ansiblecmdb/parser.py", line 44, in __init__
            "Invalid hosts file?\n".format(str(e)))
        ValueError: zero length field name in format

Partitions < 1GB are ignored

I'm not quite sure if it's a good idea to just ignore partitions that are smaller than 1GB. Or, even worse, have < 1GB space left!

What was the intention behind the decision for that? Before I submit a PR to change that I'd like to understand why it is that way. :)

-i option requires a file. directories not supported

First, thanks for the awesome tool. I've been looking for a way to visualize my infrastructure for a while now. I love this idea.

On to the issue:
ansible allows "inventory" to point at a directory, it then parses all files in that directory to create the inventory list. As such, I've broken my hosts into a directory like so:

hosts/
hosts/development
hosts/test
hosts/staging
hosts/production

and in ansible.cfg, I have:
inventory = ./hosts

The problem is, ansible-cmdb doesn't allow me to specify -i as a directory, or multiple -i statements (one per file), thus the resulting html output is partial and incomplete.

automatic testing and release

It would be useful to have an automated testing and release setup so that the latest features can be tested more easily. I could help you set this up in Travis pretty easily.

Feature Request: Make host-information collapsable

When you have hundreds of hosts in your inventory, the resulting overview gets really large.
There should be a possibility to collapse the host-information at the heading and maybe at the sub-headings, too.
There should be a setting to make the information auto-collapsed by default, maybe stored in a cookie or via cli-settings.

Better link icon for permanent link to search terms

The search box currently shows a "star" icon to the right of the search box. It can be used to link directly to the search results. However, the star icon does not properly convey this. It should be replaced by a link icon. The best way would be to include it directly as data in the stylesheet.

-i option doesn't seem to work correctly when using inventory of multiple files.

We chose to break our inventory out into multiple files as it's easier to manage and we can use a simple script that aggregates and builds lists from multiple sources.

Thus my ansible inventory is made up of approximately 60+ ini style files in a dir. When I pass that dir to -i, groups seems to only be populated with a single group that a given host is a member of, instead of all of them.

If i concatenate all of my inventory files into a single file, it works just fine with ansible-cmdb.

error on creation of overview.html

I am getting the following error when trying to import all my hosts:
./ansible-cmdb test/ > overview.html
Traceback (most recent call last):
File "./ansible-cmdb", line 84, in
sys.stdout.write(mytemplate.render(hosts=ansible.hosts, **params))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 488629: ordinal not in range(128)

I tracked that down to an fstab definition containing the German umlaut "ü".
This is an example, the problem is in the "device" line.

        {   
            "device": "//share/Prüfhinweise",
            "fstype": "cifs",
            "mount": "/home/pflegeanwendung/mounts/ake",
            "options": "rw,relatime,vers=3.0,sec=ntlmssp,cache=strict,file_mode=0660,dir_mode=0770,nounix,mapposix,rsize=65536,wsize=65536,actimeo=1",
            "size_available": 840464404480,
            "size_total": 7696581394432,
            "uuid": "NA"
        },

Vmware offline inventory

It would be nice to get info about vmware vm's even if they're powered off. I think this can be done through pyVmomi.

cpu_type list index out of range

Got this error:

If you can, also include the hosts file and the facts file for the last host
that rendered properly ('Rendering host...' in the output. If these files must
remain confidential, you can send them to [email protected] instead.
(a2)➜  acmdb ansible-cmdb -d out/ > overview.html
data_dir = /usr/local/Cellar/ansible-cmdb/1.13/ansiblecmdb/data
tpl_dir = /usr/local/Cellar/ansible-cmdb/1.13/ansiblecmdb/data/tpl
static_dir = /usr/local/Cellar/ansible-cmdb/1.13/ansiblecmdb/data/static
Parsing fact dir: out/
Reading host facts from out/dcs.dc.drivescale.com

DELETED

Reading host facts from out/u40.r2.dc.drivescale.com
template file = /usr/local/Cellar/ansible-cmdb/1.13/ansiblecmdb/data/tpl/html_fancy.tpl
Template params: {'lib_dir': '/usr/local/Cellar/ansible-cmdb/1.13/ansiblecmdb/data', 'version': '1.13', 'data_dir': '/usr/local/Cellar/ansible-cmdb/1.13/ansiblecmdb/data', 'log': <logging.RootLogger object at 0x107a4ad50>, 'columns': None}
Rendering host overview for u14.r3.hq.drivescale.com

DELETED

Rendering host overview for u14s2x.r2.dc.drivescale.com


Traceback (most recent call last):
  File "/usr/local/bin/ansible-cmdb", line 108, in <module>
    out = mytemplate.render(hosts=ansible.hosts, **params)
  File "/usr/local/Cellar/ansible-cmdb/1.13/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/local/Cellar/ansible-cmdb/1.13/mako/runtime.py", line 803, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/local/Cellar/ansible-cmdb/1.13/mako/runtime.py", line 835, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/local/Cellar/ansible-cmdb/1.13/mako/runtime.py", line 860, in _exec_template
    callable_(context, *args, **kwargs)
  File "/usr/local/Cellar/ansible-cmdb/1.13/ansiblecmdb/data/tpl/html_fancy.tpl", line 522, in render_body
    <td>${col["func"](host)}</td>
  File "/usr/local/Cellar/ansible-cmdb/1.13/ansiblecmdb/data/tpl/html_fancy.tpl", line 0, in col_cpu_type

  File "/usr/local/Cellar/ansible-cmdb/1.13/ansiblecmdb/data/tpl/html_fancy.tpl", line 92, in render_col_cpu_type
    ${ cpu_type[-1] }
IndexError: list index out of range

Whoops, it looks like something went wrong while rendering the template.

The reported error was: list index out of range

Make clean git -i

Hi Ferry!

when trying to build a release with the Makefile, the git clean -i -d -x -f fails because of missing -i in my git version (1.7.9.5).

git -i is interactive mode. Is this needed when building a release? I think make should run automatically.

Mem usage

How memory usage is measured?

One graph shows ( 7.6 / 9.8GiB ) but I type:

$ free -m

total used free shared buffers cached

  • Mem: 10001 9636 364 0 749 1119
  • -/+ buffers/cache: 7767 2233
  • Swap: 1905 201 1704

That would be 364MB free.

Feature request: support dynamic inventories

Example output of a dynamic inventory script. Where IMAP is a group name, ipaddr a host variable and virt16.example.com a host.

{
    "IMAP": {
        "hosts": [
            "virt16.example.com"
        ]
    },
    "_meta": {
        "hostvars": {
            "virt16.dte3.netsol.com": {
                "ipaddr": "1.1.1.1"
            }
        }
    }
}

Error installing on Amazon AMI

yum install ansible-cmdb*.rpm

Transaction check error:
  file / from install of ansible-cmdb-1.2-2.noarch conflicts with file from package filesystem-2.4.30-3.8.amzn1.x86_64
  file /usr/bin from install of ansible-cmdb-1.2-2.noarch conflicts with file from package filesystem-2.4.30-3.8.amzn1.x86_64
  file /usr/lib from install of ansible-cmdb-1.2-2.noarch conflicts with file from package filesystem-2.4.30-3.8.amzn1.x86_64

ansible-cmdb : 'NoneType' object has no attribute 'get'

a)
$ ansible --version
ansible 2.0.0.2

$ ansible-cmdb --version
ansible-cmdb v1.11

List of hosts:
$ ansible -i hosts all --list-hosts
hosts (3):
client01.example.com
client02.example.com
opensuse.example.com

b)
$ ansible-cmdb -d -i hosts cmdb/ > cmdb.html
data_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data
tpl_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/tpl
static_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/static
Parsing fact dir: cmdb/
Reading host facts from cmdb/client02.example.com
Reading host facts from cmdb/opensuse.example.com
Reading host facts from cmdb/client01.example.com
Parsing host vars (dir): hosts
template file = /usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl
Template params: {'lib_dir': '/usr/lib/ansible-cmdb/ansiblecmdb/data', 'version': '1.11', 'data_dir': '/usr/lib/ansible-cmdb/ansiblecmdb/data', 'log': <logging.RootLogger object at 0x7f114ab72250>, 'columns': None}
Rendering host overview for opensuse.example.com
Rendering host overview for client02.example.com
Rendering host overview for client01.example.com

Traceback (most recent call last):
File "/usr/bin/ansible-cmdb", line 108, in
out = mytemplate.render(hosts=ansible.hosts, *_params)
File "/usr/lib/ansible-cmdb/mako/template.py", line 443, in render
return runtime.render(self, self.callable, args, data)
File "/usr/lib/ansible-cmdb/mako/runtime.py", line 803, in _render
*_kwargs_for_callable(callable, data))
File "/usr/lib/ansible-cmdb/mako/runtime.py", line 835, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/usr/lib/ansible-cmdb/mako/runtime.py", line 860, in exec_template
callable
(context, _args, *_kwargs)
File "/usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl", line 487, in render_body
${col"func"}
File "/usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl", line 0, in col_dtap

File "/usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl", line 44, in render_col_dtap
${host['hostvars'].get('dtap', '')}
AttributeError: 'NoneType' object has no attribute 'get'

Whoops, it looks like something went wrong while rendering the template.

The reported error was: 'NoneType' object has no attribute 'get'

The output is probably not correct.
You can report a bug on the issue tracker:

https://github.com/fboender/ansible-cmdb/issues

Please include the debugging output (-d switch) in the report!
/data/ansible$

Documentation about the rhel/centos installation is not correct

Hey,

I started to use ansible-cmdb and I like what I see so far :)

There is one small error in the documentation, where you describe the how to install the rpm package on rhel/centos, the right should look like this:

sudo yum install ansible-cmdb*.rpm

Mention supplied templates

I guess, right now two templates exist, the fancy html template and the txt_table.
I think the different templates should be mentioned in the readme and maybe also in the cli-help.

KeyError: u'ansible_ovs-system'

Xenserver 6.5 inventory ansible_interfaces:

    "ansible_interfaces": [
        "eth0",.
        "eth3",.
        "lo",.
        "ovs-system",.
        "eth2",.
        "vif1.0",.
        "eth1",.
        "xenbr5",.
        "xenbr4",.
        "eth5",.
        "eth4",.
        "xenbr1",.
        "xenbr0",.
        "xenbr3",.
        "xenbr2"
    ],. 

$ ansible-cmdb out/ > cmdb/overview.html
Traceback (most recent call last):
File "/usr/local/bin/ansible-cmdb", line 134, in
sys.stdout.write(mytemplate.render(hosts=ansible.hosts))
File "/usr/lib/python2.7/site-packages/mako/template.py", line 443, in render
return runtime.render(self, self.callable, args, data)
File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 783, in _render
**kwargs_for_callable(callable, data))
File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 815, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 841, in exec_template
callable
(context, _args, *_kwargs)
File "_usr_local_lib_ansible_cmdb_html_fancy_tpl", line 335, in render_body
KeyError: u'ansible_ovs-system'

if i remove ovs-system ansible-cmdb works

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.