Overview
Ansible CMDB is a tool that takes the output of Ansible’s fact gathering (the output of the setup module) and converts it into an overview in HTML, JSON, CSV,… format containing system configuration information.
Features:
- Collect detailed host information, such as hardware specifications, operating systems, software versions, IP addresses,…
- Generate an overview report of the infrastructure.
- Track configuration changes over time.
Benefits:
- Helps administrators gain a comprehensive view of the system.
- Makes it easy to look up configuration information.
- Supports resource planning and management.
Installing Ansible CMDB
Environment: Use a Control Server (Ubuntu 24) with Ansible CMDB installed.
First, install the redirection (symlink) package so that the command python points to python3. This is necessary because newer Linux distributions such as Ubuntu 20.04+ or Debian 11+, do not include the python command by default because Python 2 has been deprecated, and only python3 is preinstalled.
apt install python-is-python3

Next, install the package ansible-cmdb using pip3.
pip3 install --break-system-packages ansible-cmdb

Check whether Ansible CMDB was installed successfully by running the following command:
ansible-cmdb --version

At this point, you will encounter the error ModuleNotFoundError: No module named 'imp' because imp is a deprecated module that has been removed entirely from Python 3.12.
Therefore, you need to replace imp with importlib in the / fileusr/local/lib/python3.12/dist-packages/ansiblecmdb/render.py.
from importlib import import_module

Verify that Ansible CMDB is working:

How to Use Ansible CMDB
Step 1: Generate Ansible output for the remote servers in the inventory using the setup module.
ansible -m setup -i inventory-lab --tree out/ all

These outputs will be saved in the directory out and split into separate files corresponding to each remote server.
Step 2: Use ansible cmdb to generate the CMDB overview page.
Ansible CMDB supports several templates for generating HTML pages, JSON, plain-text tables, CSV, SQL,…. You can choose any of them; if no specific template is specified, it will use the HTML template html_fancy by default.
Run the command below and save the file as overview.html.
ansible-cmdb -i inventory-lab out > overview.html

Open the file overview.html You will see a comprehensive overview of the basic parameters and configuration details that Ansible has collected from the remote servers, such as hostname, OS, RAM, CPU, IP,…

If you need to quickly view specific information about the remote servers, you can configure Ansible CMDB to generate the output in table format.
In the example below, I list the OS, OS architecture, RAM, and number of CPU cores.

Conclusion
With Ansible CMDB, you can easily create detailed reports from system data collected by Ansible. This is a useful tool that every system administrator should try!