Ansible 插件 实现cmdb功能

https://github.com/fboender/ansible-cmdb

https://github-production-release-asset-2e65be.s3.amazonaws.com/37154906/83249f88-1f18-11e8-8532-373669cb8301?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20180415%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180415T092430Z&X-Amz-Expires=300&X-Amz-Signature=f81d5fc69fcbb0d154e3b17bf69f43453ce27cabda25a04f5ce4fe1ec300f424&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B filename%3Dansible-cmdb-1.26.1.tar.gz&response-content-type=application%2Foctet-stream

tar -xvf ansible-cmdb-1.26.1.tar.gz 
cd ansible-cmdb-1.26.1/
make install
ansible -m setup --tree out/ all
ansible-cmdb out/ > overview.html


mysql数据库安装		
yum install mariadb-server mariadb -y
systemctl enable mariadb
systemctl start mariadb 

将数据库导入数据	
ansible-cmdb -t sql out > cmdb.sql
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ansiblecmdb        |
| jumpserver         |
| mysql              |
| performance_schema |
+--------------------+
5 rows in set (0.00 sec)

MariaDB [(none)]> use ansiblecmdb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [ansiblecmdb]> show tables;
+-----------------------+
| Tables_in_ansiblecmdb |
+-----------------------+
| hosts                 |
+-----------------------+
1 row in set (0.00 sec)

MariaDB [ansiblecmdb]> select * from hosts;
+--------------+------------------------+--------------+---------+------------+--------+-----------------------+---------------+----------------+-----------+-----------+------------------------------------------+-------+------+------------+-----------+
| name         | fqdn                   | main_ip      | os_name | os_version | system | kernel                | arch_hardware | arch_userspace | virt_type | virt_role | cpu_type                                 | vcpus | ram  | disk_total | disk_free |
+--------------+------------------------+--------------+---------+------------+--------+-----------------------+---------------+----------------+-----------+-----------+------------------------------------------+-------+------+------------+-----------+
| 172.16.8.248 | devops-jenkins-node248 | 172.16.8.248 | CentOS  | 7.4.1708   | Linux  | 3.10.0-693.el7.x86_64 | x86_64        | x86_64         | VMware    | guest     | Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz |     1 |    1 |       12.5 |       1.7 |
| 172.16.8.50  | devops-docker-node50   | 172.16.8.50  | CentOS  | 7.4.1708   | Linux  | 3.10.0-693.el7.x86_64 | x86_64        | x86_64         | VMware    | guest     | Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz |     2 |  1.8 |       12.5 |       3.7 |
| 172.16.8.246 | devops-gitlab-node246  | 172.16.8.246 | CentOS  | 7.4.1708   | Linux  | 3.10.0-693.el7.x86_64 | x86_64        | x86_64         | VMware    | guest     | Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz |     1 |  1.8 |       12.5 |       3.6 |
| 172.16.8.119 | devops-saltstack-node2 | 172.16.8.119 | CentOS  | 7.4.1708   | Linux  | 3.10.0-693.el7.x86_64 | x86_64        | x86_64         | VMware    | guest     | Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz |     1 |    1 |       12.5 |       1.7 |
| 172.16.8.118 | devops-saltstack-node1 | 172.16.8.118 | CentOS  | 7.4.1708   | Linux  | 3.10.0-693.el7.x86_64 | x86_64        | x86_64         | VMware    | guest     | Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz |     1 |    1 |       12.5 |       2.3 |
+--------------+------------------------+--------------+---------+------------+--------+-----------------------+---------------+----------------+-----------+-----------+------------------------------------------+-------+------+------------+-----------+
5 rows in set (0.00 sec)


将数据写入CSV文件
ansible-cmdb -t csv out > cmdb.csv

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiegh2014/article/details/79950962
个人分类: Python
上一篇python-saltstack实现cmdb资产统计功能
下一篇Docker 网络管理
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭