<commit_before>Ansible Configuration Management Database
=========================================

About
-----

This script takes the output of Ansible's `setup` module and converts it into a
static HTML overview page containing system configuration information.

It supports multiple templates and extending information gathered by Ansible
with custom data.

[HTML example](https://rawgit.com/fboender/ansible-cmdb/master/example/html_fancy.html) output.

Installation
------------

Get the package for your distribution from the [Releases page](https://github.com/fboender/ansible-cmdb/releases)

For **Debian / Ubuntu** systems:

    sudo dpkg -i ansible-cmdb*.deb

For **Redhat / Centos** systems:

    sudo yum -i -i ansible-cmdb*.rpm

For **Other** systems:

    tar -vxzf ansible-cmdb*.tar.gz
    cd ansible-cmdb*
    sudo make install

Usage
-----

### Basic

First, generate Ansible output for your hosts:

	mkdir out
	ansible -m setup --tree out/ all

Next, call ansible-cmdb on the resulting `out/` directory to generate the CMDB
overview page:

	ansible-cmdb out/ > overview.html

The default template is `html_fancy`, which required Jquery and a JQuery
library. It can therefor not be opened in your browser using `file:///`, but
must be served over http or https. You can do so reasonbly easy using Python's
built-in webserver, which will serve files to from the directory it is started
in:

    $ python -m SimpleHTTPServer 
    Serving HTTP on 0.0.0.0 port 8000 ...
    $ xdg-open http://localhost:8000/overview.html

### Templates

ansible-cmdb offers multiple templates. You can choose your template with the
`-t` or `--template` argument:

	ansible-cmdb -t tpl_custom out/ > overview.html

The 'html_fancy' template is the default. It can be easily extended by copying
it and modifying the `cols` definition at the top. It should be served over
HTTP, as it uses CDN Jquery libs.

Ansible-cmdb currently provides the following templates out of the box:

* `html_fancy`: A fancy HTML page that used JQuery and DataTables to give you a
  searchable, sortable table overview of all hosts with detailed information
  just a click away.
* `txt_table`: A quick text table summary of the available hosts with some
  minimal information.

### Inventory scanning

Ansible-cmdb can read your inventory file (`hosts`, by default) and extract
useful information from it such as:

- All the groups a host belongs to.
- Host variables. These are optional key/value pairs for each host which can be
  used in playbooks. They are scanned by ansible-cmdb and get added to a hosts
  discovered facts under the 'hostvars' section.

The ''fancy'' template uses four extra fields:

- `groups`: A list of Ansible groups the host belongs too
- `dtap`: Whether a host is a development, test, acceptance or production system.
- `comment`: A comment for the host.
- `ext_id`: An external unique identifier for the host.

For example, lets say we have the following `hosts` file:

	[cust.megacorp]
	db1.dev.megacorp.com   dtap=dev  comment="Old database server"
	db2.dev.megacorp.com   dtap=dev  comment="New database server"
	test.megacorp.com      dtap=test 
	acc.megacorp.com       dtap=acc  comment="24/7 support"
	megacorp.com           dtap=prod comment="Hosting by Foo" ext_id="SRV_10029"
	
	[os.redhat]
	megacorp.com
	acc.megacorp.com
	test.megacorp.com<commit_msg>Fix name of template in README.<commit_after>Ansible Configuration Management Database
=========================================

About
-----

This script takes the output of Ansible's `setup` module and converts it into a
static HTML overview page containing system configuration information.

It supports multiple templates and extending information gathered by Ansible
with custom data.

[HTML example](https://rawgit.com/fboender/ansible-cmdb/master/example/html_fancy.html) output.

Installation
------------

Get the package for your distribution from the [Releases page](https://github.com/fboender/ansible-cmdb/releases)

For **Debian / Ubuntu** systems:

    sudo dpkg -i ansible-cmdb*.deb

For **Redhat / Centos** systems:

    sudo yum -i -i ansible-cmdb*.rpm

For **Other** systems:

    tar -vxzf ansible-cmdb*.tar.gz
    cd ansible-cmdb*
    sudo make install

Usage
-----

### Basic

First, generate Ansible output for your hosts:

	mkdir out
	ansible -m setup --tree out/ all

Next, call ansible-cmdb on the resulting `out/` directory to generate the CMDB
overview page:

	ansible-cmdb out/ > overview.html

The default template is `html_fancy`, which required Jquery and a JQuery
library. It can therefor not be opened in your browser using `file:///`, but
must be served over http or https. You can do so reasonbly easy using Python's
built-in webserver, which will serve files to from the directory it is started
in:

    $ python -m SimpleHTTPServer 
    Serving HTTP on 0.0.0.0 port 8000 ...
    $ xdg-open http://localhost:8000/overview.html

### Templates

ansible-cmdb offers multiple templates. You can choose your template with the
`-t` or `--template` argument:

	ansible-cmdb -t tpl_custom out/ > overview.html

The 'html_fancy' template is the default. It can be easily extended by copying
it and modifying the `cols` definition at the top. It should be served over
HTTP, as it uses CDN Jquery libs.

Ansible-cmdb currently provides the following templates out of the box:

* `html_fancy`: A fancy HTML page that used JQuery and DataTables to give you a
  searchable, sortable table overview of all hosts with detailed information
  just a click away.
* `txt_table`: A quick text table summary of the available hosts with some
  minimal information.

### Inventory scanning

Ansible-cmdb can read your inventory file (`hosts`, by default) and extract
useful information from it such as:

- All the groups a host belongs to.
- Host variables. These are optional key/value pairs for each host which can be
  used in playbooks. They are scanned by ansible-cmdb and get added to a hosts
  discovered facts under the 'hostvars' section.

The ''html_fancy'' template uses four extra fields:

- `groups`: A list of Ansible groups the host belongs too
- `dtap`: Whether a host is a development, test, acceptance or production system.
- `comment`: A comment for the host.
- `ext_id`: An external unique identifier for the host.

For example, lets say we have the following `hosts` file:

	[cust.megacorp]
	db1.dev.megacorp.com   dtap=dev  comment="Old database server"
	db2.dev.megacorp.com   dtap=dev  comment="New database server"
	test.megacorp.com      dtap=test 
	acc.megacorp.com       dtap=acc  comment="24/7 support"
	megacorp.com           dtap=prod comment="Hosting by Foo" ext_id="SRV_10029"
	
	[os.redhat]
	megacorp.com
	acc.megacorp.com
	test.megacorp.com
{'fraction_non_alphanumeric': 0.09343995261365319, 'fraction_numerical': 0.006515622686213534, 'mean_word_length': 3.79347054648687, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1934169', 'n_tokens_mistral': 2101, 'n_tokens_neox': 1950, 'n_words': 856}