问题:hosts配置完密码后,ping主机出错,如下
[root@localhost ansible]# ansible -i hosts all -m ping
192.168.59.130 | FAILED! => {
"msg": "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."
}
原因,ssh第一次登陆服务器需要输入yes/no ;信息存入本机/root/.ssh/known_hosts
解决方法:
在您所要执行ansible的目录下修改ansible.cfg
echo "host_key_checking = False" >>ansible.cfg #禁用SSH密钥主机检查