Github地址: https://github.com/fboender/ansible-cmdb
从facts收集信息,生成主机概述
1、安装
wget https://github.com/fboender/ansible-cmdb/releases/download/1.17/ansible-cmdb-1.17.tar.gz tar zxf ansible-cmdb-1.17.tar.gz cd ansible-cmdb-1.17 make install
2、生成所有主机得facts信息
ansible -m setup --tree out/ all
3、生成web页面信息
ansible-cmdb out/ > overview.html
4、默认模板采用html_fancy,文件存放在/usr/local/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl
如果facts用了本地缓存,-f指定缓存目录即可。
ansible-cmdb -f /path/to/facts/dir > overview.html
5、以资产列表得形式统计出ansible主机信息。
ansible-cmdb -t txt_table --columns name,os,ip,mem,cpus out/
6、输出csv格式的主机信息
ansible-cmdb -t csv -i /etc/ansible/hosts out/ "Name","OS","IP","Arch","Mem","MemFree","MemUsed","CPUs","Virt","Disk avail" "192.168.40.135","Debian 10","192.168.40.135","x86_64/x86_64","12g","11g","0g","2","VMware/guest","1.0g, 0.0g, 8.0g, 20.0g, 108.0g" 192.168.40.134: No info collected192.168.40.133: No info collected"192.168.40.132","CentOS 7.9","192.168.40.132","x86_64/x86_64","12g","11g","1g","1","VMware/guest","0.0g, 49.0g, 44.0g"
7、输出sql文件,导入数据到mysql或者SQLite
ansible-cmdb -t sql -i hosts out/