"CMDB" Installation and use of the Ansible plugin

Source: Internet
Author: User
Tags import database

Here is an example of the installation of the Ansible-cmdb plugin, Web presentation, and importing MySQL database
Installation Environment:
Centos7
ip:10.1.1.10

1. Install Apache:
[Email protected] ~]yum install httpd
Because you want to use Web browsing, install Apache

2. Install Ansible-cmdb plug-in

[Email protected] opt]# wget https://files.pythonhosted.org/packages/37/1b/ 1fcff0a38a4e07d9d3f75113494ec0b25fd271b650bda52907ae1a80cbfb/ansible-cmdb-1.27.tar.gz

[Email protected] opt]# TAR-XVF ansible-cmdb-1.27.tar.gz
[Email protected] opt]# CD ansible-cmdb-1.27
[[email protected] ansible-cmdb-1.27]# python setup.py install

After the installation is complete, copy the ansible-cmdb.py file from the src (/ansible-cmdb-1.27/src) directory of the extracted directory to the/usr/bin/directory.

If you do not copy the ansible-cmdb.py file to the/usr/bin/directory, the following generation of HTML files or other file formats will
Error message: couldn ' t find/usr/bin/ansible-cmdb.py in. or/usr/bin/. /lib/ansible-cmdb/or/usr/bin/. /lib/ansiblecmdb/(CWD=/OPT/ANSIBLE-CMDB-1.27/SRC)

3. Use

(1), Generate facts information for all hosts
[Email protected] ~]# mkdir?out
[email protected] ~]# LL
Drwxr-xr-x. 2 root root June 20:30 out

[Email protected] ~]# ansible all-m setup--tree out/

(2), generate the facts information generated by the Web page
[Email protected] ~]# Ansible-cmdb out/> overview.html
[email protected] ~]# LL
Drwxr-xr-x. 2 root root June 20:30 out
-rw-r--r--. 1 root root 118584 June 20:43 overview.html

A, in the form of assets list statistics Ansible host information.

[Email protected] ~]# ansible-cmdb-t txt_table--columns Name,os,ip,mem,cpus out/
Name OS IP Mem CPUs

10.1.1.12 CentOS 7.3.1611 192.168.43.94 0g 1
localhost CentOS 7.3.1611 192.168.43.187 0g 1
[Email protected] ~]#

B. Copy the overview.html to the/var/www/html/test/directory
[email protected] ~]# CP overview.html/var/www/html/test
You may need to change permissions:
[Email protected] ~]# chown-r apache:apache/var/www/html/test/

(3), on the Web page display:
Http://10.1.1.10/test/overview.html

(4), output SQL file, import data to MySQL or SQLite

A, output the file in SQL format:
[[email protected] ~]# ansible-cmdb-t sql out > Cmdb.sql

[email protected] ~]# LL
-rw-r--r--. 1 root root 1749 June 21:34 Cmdb.sql
Drwxr-xr-x. 2 root root June 20:30 out
-rw-r--r--. 1 root root 118584 June 20:43 overview.html

[Email protected] ~]#

B. Import the database into data
[Email protected] ~]# systemctl start mysqld

[[email protected] ~]# mysql-uroot-p Ansdb < cmdb.sql//import database into data

[Email protected] ~]# mysql-uroot-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server version:5.7.21 MySQL Community Server (GPL)

Copyright (c), 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| Ansdb |
| MySQL |
| Performance_schema |
| SYS |
+--------------------+
5 rows in Set (0.53 sec)

Mysql> Use Ansdb
Database changed

Mysql>
Mysql> Show tables;
+-----------------+
| Tables_in_ansdb |
+-----------------+
| Hosts |
+-----------------+
1 row in Set (0.03 sec)

Mysql> SELECT * from the 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 |
+-----------+-------+----------------+---------+------------+--------+-----------------------+---------------+- ---------------+-----------+-----------+------------------------------------------+-------+------+------------+ -----------+
| 10.1.1.12 | Node1 | 192.168.43.94 | CentOS | 7.3.1611 | Linux | 3.10.0-514.el7.x86_64 | x86_64 | x86_64 | VMware | Guest | Intel (R) Core (TM) i3-2330m CPU @ 2.20GHZ | 2 | 0.5 | 50 | 47.1 |
| localhost | Node1 | 192.168.43.187 | CentOS | 7.3.1611 | Linux | 3.10.0-514.el7.x86_64 | x86_64 | x86_64 | VMware | Guest | Intel (R) Core (TM) i3-2330m CPU @ 2.20GHZ | 2 | 0.5 | 50 | 46.9 |
+-----------+-------+----------------+---------+------------+--------+-----------------------+---------------+- ---------------+-----------+-----------+------------------------------------------+-------+------+------------+ -----------+
2 rows in Set (0.00 sec)

Mysql>

"CMDB" Installation and use of the Ansible plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.