首先安裝 ansible-cmdb
直接pip install ansible-cmdb
安裝
然后執行收集信息命令
ansible all -m setup >/tmp/out/
修改下ansible-cmd 讓它默認以python3
版本運行
vim $(which ansible-cmdb)
刪除這一行PY_BIN=$(which python)
刪除方法:按dd
之后 ESC
+:
+x
+enter
保存即可
現在讓ansible-cmdb解析數據
ansible-cmdb /tmp/out/ >/tmp/hosts.html
瀏覽器打開就能看到這樣的頁面了