A, ansibles configuration and testing
1, ansible mounting configuration
The use of public key batch management
[LB02 the root @ ~] # SSH-keygen - T # Create RSA public key [LB02 the root @ ~] # SSH -copy- ID -i ~ /. SSH /id_rsa.pub the root @ 192.168 . 11.206 # copied to the public key management host. SSH / authorized_keys file, password-free logon achieve remote management host [root @ LB02 ~] # SSH -copy- the above mentioned id -i ~ /. SSH /id_rsa.pub root @ 192.168 . 11.207 # to copy the public key management host SSH / authorized_keys file, password-free logon achieve remote management host Note: If a password is generated when the key is, when the ansible every command execution, will be prompted to enter the key password, you can use the following command Remember password. Agent-SSH BSH SSH-the Add ~/.ssh/id_rsa
2, control terminal installation program ansible
Online installation:
[root@LB02 ~]# yum install epel-release -y [root@LB02 ~]# yum install ansible -y
Offline installation:
[root@LB02 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm [root@LB02 ~]# yum install ansible -y
3, configuration ansible
[root @ LB02 ~] # vim / etc / ansible / hosts [web01] # client hostname 192.168 . 11.206 # client IP address [web02] 192.168 . 11.207 [Web: Children] web01 web02
4, authentication ansible, detecting a communication port through ssh
[root@LB02 ~]# ansible web -m ping #能正常ping通客户端所有主机 192.168.11.206 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" } 192.168.11.207 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" }
5, test
[LB02 the root @ ~] # ansible Web --list- the hosts # view all connected hosts normally the hosts ( 2 ): 192.168 . 11.206 192.168 . 11.207
Two, ansible command syntax and modules