Skip to main content

Synopsis

ansible-cmdb [options] <dir> > output.html
The <dir> argument specifies the directory containing Ansible fact files generated by ansible -m setup --tree <dir> all.

Command-Line Options

<dir>
string
required
Directory containing Ansible fact files or fact cache files. This is the output directory from ansible -m setup --tree <dir> command.
-t, --template
string
default:"html_fancy"
Template to use for output generation. Can be a template name or a path to a custom template file.See Templates for available templates.
-i, --inventory
string
Path to Ansible inventory file, directory, or dynamic inventory script. Multiple inventories can be specified by separating them with commas (no spaces).This option enables ansible-cmdb to read:
  • Host groups
  • Host variables (including dtap, comment, ext_id)
  • Group variables from group_vars/ and host_vars/ directories
See Inventory Scanning for details.
-f, --fact-cache
boolean
default:false
Indicates that <dir> contains fact-cache files instead of regular setup output files.When enabled, this option applies to all fact directories specified. You cannot mix fact-cache and regular setup directories.See Fact Caching for details.
-p, --params
string
Parameters to pass to the template. Multiple parameters are separated by commas with no spaces.Format: key1=value1,key2=value2Example:
ansible-cmdb -p local_js=1,collapsed=1 out/ > overview.html
See Templates for template-specific parameters.
-c, --columns
string
Comma-separated list of column IDs to display in the output. Only applicable to templates that support columns (e.g., html_fancy, txt_table).Example:
ansible-cmdb -c name,os,ip,mem,cpus facts/
-C, --cust-cols
string
Path to a custom columns definition file. Allows you to define additional columns using jsonxs expressions or Mako templates.Only supported by html_fancy and html_fancy_split templates.Example:
ansible-cmdb -C custom_columns.conf -i hosts out/ > cmdb.html
--exclude-cols
string
Comma-separated list of column IDs to exclude from the output. Works with templates that support columns.Example:
ansible-cmdb --exclude-cols mem_usage,swap_usage facts/
-l, --limit
string
Limit hosts included in the output using Ansible-style patterns. Supports:
  • all - all hosts
  • Individual hosts: host1.example.com
  • Groups: webservers
  • Inversion: !groupname
  • Combinations: all:!development:db1.example.com
Requires the -i option to be specified.See Limiting Hosts for details.
-d, --debug
boolean
default:false
Enable debug output. Shows detailed logging information during execution.
-q, --quiet
boolean
default:false
Suppress warning messages. Only error messages will be displayed.
--version
boolean
Display the program version number and exit.
-h, --help
boolean
Show help message with all options and exit.

Basic Usage Examples

mkdir out
ansible -m setup --tree out/ all
ansible-cmdb out/ > overview.html

Advanced Examples

Multiple fact directories

You can specify multiple directories to overlay facts:
ansible-cmdb out/ out_extend/ out_custom/ > overview.html
This allows you to:
  • Override facts
  • Add missing information
  • Create manual host entries
  • Add custom facts

Combining options

ansible-cmdb \
  -t html_fancy_split \
  -i hosts \
  -p local_js=1,collapsed=1 \
  --exclude-cols mem_usage,swap_usage \
  -l 'production' \
  out/

Notes

ansible-cmdb is a shell wrapper script that finds the correct Python binary and the ansible-cmdb.py script location. If it fails, you can manually specify:
/opt/python3/bin/python /opt/ansible-cmdb/src/ansible-cmdb.py out/ > overview.html
When using --fact-cache, you cannot mix fact-cache directories with regular setup output directories. All specified directories must be of the same type.

Build docs developers (and LLMs) love