CentOS system: installation and configuration of automatic operation and maintenance tool ansible

Time:2021-5-29

1、 Introduction to ansible tool

ansibleIs a new automatic operation and maintenance tool, based onPythonDevelopment, a collection of many operation and maintenance tools (puppet, Cfengine, chef, func, fabric) the advantages of the implementation of theBatch system configurationBatch program deploymentBatch run commandAnd other functions.

2、 Installation of ansible

1. Because it’s a simple test of ansible, we usethreeplatformCentOS 7.4The server performs a series of cooperative operations.

CentOS system: installation and configuration of automatic operation and maintenance tool ansible

2. First, addepel-releaseThird party suite sources

yum install -y epel-release

CentOS system: installation and configuration of automatic operation and maintenance tool ansible

3. UseyuminstallAnsible

yum install -y ansible

CentOS system: installation and configuration of automatic operation and maintenance tool ansible

3、 Configuration of ansible

1. Install on all nodesYUMSSHpython

yum install -y openssh-server python
Management side installation configuration

CentOS system: installation and configuration of automatic operation and maintenance tool ansible

Managed end 1 installation configuration

CentOS system: installation and configuration of automatic operation and maintenance tool ansible

Managed end 2 installation configuration

CentOS system: installation and configuration of automatic operation and maintenance tool ansible

2. On the management interface:ssh-keygenPress all the wayenterthat will do

ssh-keygen

CentOS system: installation and configuration of automatic operation and maintenance tool ansible

3. On the management node, replace it with your ownIPaddress

ssh-copy-id 192.168.139.133
ssh-copy-id 192.168.139.134

CentOS system: installation and configuration of automatic operation and maintenance tool ansible

4. Modify configuration fileansible.cfg

vi /etc/ansible/ansible.cfg
Add the following:
inventory      = /etc/ansible/hosts
forks = 5
become = root
remote_port    = 22
host_key_checking = False
timeout = 10
log_path = /var/log/ansible.log
private_key_file = /root/.ssh/id_ras

5. Finally, view the results

cat /etc/ansible/hosts