搭建好ansible后,在/etc/ansible/hosts 文件中添加如下:
[all]
192.168.220.141 ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass=root
然后在机器上执行:
[root@localhost ansible]# ansible all -m ping
192.168.220.141 | UNREACHABLE! => {
"changed": false,
"msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh",
"unreachable": true
}
好奇怪啊, 以前搞的时候挺顺利的!
不得已只好
[root@localhost ansible]# ansible all -m ping -vvvv
......
......
......
问题原因:
Since you are not using SSH keys to authenticate, you must try running "export ANSIBLE_SCP_IF_SSH=y" before running ansible-playbook with -vvv option.
最后找到解决方法:
[root@localhost ansible]#
export ANSIBLE_SCP_IF_SSH=y ##执行这个命令即可正常!
[root@localhost ansible]# ansible all -m ping
192.168.220.141 | SUCCESS => {
"changed": false,
"ping": "pong"
}
阅读(7805) | 评论(0) | 转发(0) |