重点:ansible互信认证部署、ansible主机和组的定义Inventory
Ansible默认是通过SSH key和远程被控制主机进行通信,当然我们可以SSH password来和远程主机进行通信。 如果使用SSH KEY,则要将控制主机上的公钥放到被监控主机的/root/.ssh/authorized_keys文件中。
1、安装ansible和简单的配置的设置
安装epel源再yum安装ansible:
# yum installl ansible -y
# vim /etc/ansible/ansible.cfg
。。。。
# uncomment this to disable SSH key host checking
host_key_checking = False
2、主机组inventory设置
# cat /root/ans/ansible_inventory.txt
[front]
10.11.7.224 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=xuAKCeU
10.11.5.84 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=pwByh
3、创建SSH认证文件
# ssh-keygen -t rsa -N yOdaf
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):/root/.ssh/sshhost
Your> Your public key has been saved in /root/.ssh/ansssh.pub.
The key fingerprint is:
4b:8a:fb:f6:ca:58:81:b1:49:4b:47:55:c6:c1:61:df root@ecloud
The key's randomart image is:
+--[ RSA 2048]----+
| ...+*o |
| . oo. . |
| + . . E |
| o B |
| = . S |
| . + . |
| . o . |
| =. |
| oo+o. |
+-----------------+