配置主机
1、下载安装所需安装包
[root@server1 ansible]# ls
ansible-2.7.8-1.el7.noarch.rpm
ansible-tower-setup-bundle-3.4.2-1.el7.tar.gz
libtomcrypt-1.17-25.el7.x86_64.rpm
libtommath-0.42.0-5.el7.x86_64.rpm
python2-crypto-2.6.1-13.el7.x86_64.rpm
python2-jmespath-0.9.0-1.el7.noarch.rpm
python-httplib2-0.9.2-0.1.el7.noarch.rpm
python-keyczar-0.71c-2.el7.noarch.rpm
python-paramiko-2.1.1-0.9.el7.noarch.rpm
sshpass-1.06-1.el7.x86_64.rpm
[root@server1 ansible]# yum install -y *
2、配置
[root@server1 ansible]# cd /etc/ansible/
[root@server1 ansible]# ls
ansible.cfg hosts roles
[root@server1 ansible]# vim hosts
测试ping模块:先ping——>输入yes,再加-k参数
[root@server1 ansible]# ansible server1 -m ping
The authenticity of host 'server1 (172.25.60.1)' can't be established.
ECDSA key fingerprint is 4a:62:22:df:00:1f:c1:37:c6:ea:b4:8c:ad:75:b3:07.
Are you sure you want to continue connecting (yes/no)? yes
server1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Warning: Permanently added 'server1,172.25.60.1' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
"unreachable": true
}
[root@server1 ansible]# ansible server1 -m ping -k
SSH password:
server1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
[root@server1 ansible]# ansible server2 -m ping
The authenticit