CentOS system: installation and configuration of automated operation and maintenance tool Ansible

Posted May 27, 20202 min read

1. Introduction to Ansible Tools

ansibleis a newly emerged automated operation and maintenance tool, based on the development ofPython, which combines the advantages of many operation and maintenance tools(puppet, cfengine, chef, func, fabric), and realizes batch system configurationandbatch program deployment , Batch run command` and other functions.

Second, Ansible installation

1. Because it is a simple test on Ansible, a series of collaborative operations are performed using Three CentOS 7.4` servers.

image

2. First add the source of epel-release third-party packages

yum install -y epel-release

image

3. Use yum to install Ansible

yum install -y ansible

image

3. Configuration of Ansible

1. Install YUM, SSH, python on all nodes

yum install -y openssh-server python
Management terminal installation and configuration

image

Installation and configuration of the managed terminal 1

image

Installation and configuration of the managed terminal 2

image

2. Execute on the management interface:ssh-keygen, press Enter all the way

ssh-keygen

image

3. Execute on the management node and replace it with your own IP address

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

image

4. Modify the configuration file ansible.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. Lastly check the results

cat/etc/ansible/hosts