Quick Start Guide
This guide will walk you through generating your first Configuration Management Database using ansible-cmdb.Prerequisites
Before you begin, ensure you have:- Ansible installed on your system
- ansible-cmdb installed (see Installation)
- SSH access to your hosts
- Ansible inventory configured
Basic Workflow
Gather facts from your hosts
First, use Ansible to gather facts from all your hosts. This creates JSON files containing system information for each host.Create an output directory and gather facts:After running this command, you should see files like:
The
-m setup module gathers facts from hosts, and --tree out/ saves each host’s facts to a separate file in the out/ directory. The all parameter targets all hosts in your inventory.Generate the CMDB overview
Run ansible-cmdb on the facts directory to generate an HTML overview:This uses the default
html_fancy template to create a dynamic, searchable HTML page.Complete Working Example
Here’s a complete example showing the entire process:Using Inventory Files
To include host and group variables from your inventory, use the-i option:
- All groups a host belongs to
- Host variables defined in the inventory
- Variables from
host_vars/andgroup_vars/directories
Example Inventory with Variables
hosts
The
html_fancy template supports special variables:dtap- Environment type (development/test/acceptance/production)comment- Host commentext_id- External identifiergroups- List of groups (automatically populated)
Template Options
HTML Fancy Parameters
Customize the HTML output with template parameters:Selecting Columns
Show only specific columns in the output:Limiting Hosts
Generate output for specific hosts or groups:Using Fact Cache
If you’re using Ansible’s fact caching feature, you can use those cached facts directly:Configure Ansible Fact Caching
Add to youransible.cfg:
ansible.cfg
The
--fact-cache option applies to all fact directories you specify. You cannot mix fact-cache directories with normal setup directories.Advanced: SQL Export
Generate SQL output for importing into a database:Advanced: Split Output
For large numbers of hosts, use the split template for better performance:cmdb/ directory with:
index.html- Main overview page- Separate HTML files for each host’s details
Troubleshooting
No facts gathered
If ansible-cmdb shows no hosts, verify your facts were gathered correctly:Python interpreter issues
If you get Python-related errors, you can manually specify the Python interpreter:Template not found
Verify available templates:html_fancy(default)html_fancy_splitcsvjsonmarkdownsqltxt_table
Next Steps
Custom Columns
Learn how to add custom columns with JSONPath expressions
Extending Facts
Override and extend facts with custom data
Custom Templates
Create your own templates using Mako
Host Variables
Use special variables like dtap, comment, and ext_id