Skip to main content

Ansible Cmdb Host Data Collection

utilities sysadmin

ansible-cmdb makes it simple to collect summary data about all the machines on your home network. For example, how much RAM and disk space they’re using.

Here’s how I set it up to generate a regular HTML report that I can view in my web browser.

Install
#

pip install ansible-cmdb

Make output directories
#

# Directory for dumping stats from each host
sudo mkdir /var/www/html/ansible
# Directory for creating the HTML page
sudo chown paul:paul /var/www/html/ansible
mkdir /var/www/html/ansible/cmdb

Create a shell script
#

#!/bin/bash
# ~/scripts/ansible/monitor-get-stats.sh
# Fetch the facts from each host, then generate a static HTML report
ANSIBLE_HOSTS="monitor" # the name of the group I want to query
                        # from my inventory (/etc/ansible/hosts)
ansible -m setup --tree ~/ansible/stats/cmdb/ "$ANSIBLE_HOSTS"
ansible-cmdb ~/ansible/stats/cmdb/ > /var/www/html/ansible/cmdb/overview.html 2>&1

Serve the report from your web server
#

You can now open the file in your web browser at file:///var/www/html/ansible/cmdb/overview.html

To host it on my webserver, so that I can access it through a simple URL, I configured Caddy.

Edit your Caddy configuration (/etc/caddy/Caddyfile), adding an entry like:

:80 my-pc.example.com {
...
        handle_path /cmdb {
                root * /var/www/html/ansible/cmdb
                try_files {path} overview.html index.html
                file_server
        }

Run sudo systemctl reload caddy and browse to ` https://my-pc.example.com/cmdb

Resources
#

Related

Ansible Installation For Daily Debian Package Updates
utilities system configuration sysadmin
Install # Performed on Debian 12 (bookworm)
Pdfcpu Commands For Manipulating Pdf Files
utilities pdf
Install # Download and extract pdfcpu.
Print CSV Files To PDF With Weasyprint
utilities development pdf python css
CSV file converted to PDF, with variable column widths and footers Printing a CSV file as a nicely formatted table is easy if you import it first into a spreadsheet like Microsoft Excel or LibreOffice Calc.