[root@server]# ansible all -m "ping"

paramiko: The authenticity of host '192.168.1.10' can't be established.
The ssh-rsa key fingerprint is 1c4ede8021ffcfa6f7788bfca4032548.
Are you sure you want to continue connecting (yes/no)?
yes
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/ansible/plugins/connection/paramiko_ssh.py", line 386, in close
key_stat = os.stat(self.keyfile)
OSError: [Errno 2] No such file or directory: '/root/.ssh/known_hosts'

 

出现以上错误

1、修改/etc/ansible/ansible.cfg文件。添加以下配置

host_key_checking = False
 

2、创建known_hosts文件

#touch /root/.ssh/known_hosts

[root@server]# ansible all -m "ping"

192.168.1.10 | SUCCESS => {
"changed": false, 
"ping": "pong"
}
192.168.1.20 | SUCCESS => {
"changed": false, 
"ping": "pong"

}