I. 对之前未连接的主机进行连结时报错如下:
[root@linux ~]# ansible webservers -m command -a ‘ls ~’ -k
SSH password:
120.76.25.191 | FAILED | rc=0 >>
Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host’s fingerprint to your known_hosts file to manage this host.
解决步骤:修改ansible.cfg文件
- vi /etc/ansible/ansible.cfg
- 找到以下行,让host_key_checking=False这行生效
uncomment this to disable SSH key host checking
host_key_checking = False
II. 在ansible安装完毕后一般需要以SSH的方式连接到需要进行管理的目标主机,一开始遇到了如下问题:
120.76.25.191 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n”,
“unreachable”: true
}<