ansible无法执行

回复 收藏
ssh可以连接、selinux关闭、iptables无规则
报错:"msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh",
详细信息:
[root@cs ~]# ansible 192.168.5.16 -m shell -a 'w' -vvvvv
Using /etc/ansible/ansible.cfg as config file
Loaded callback minimal of type stdout, v2.0
<192.168.5.16> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.5.16> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<192.168.5.16> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<192.168.5.16> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<192.168.5.16> SSH: PlayContext set ssh_common_args: ()
<192.168.5.16> SSH: PlayContext set ssh_extra_args: ()
<192.168.5.16> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r)
<192.168.5.16> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.5.16 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1471264096.55-66433255124009 `" && echo ansible-tmp-1471264096.55-66433255124009="` echo $HOME/.ansible/tmp/ansible-tmp-1471264096.55-66433255124009 `" ) && sleep 0'"'"''
<192.168.5.16> PUT /tmp/tmpHBP57J TO /root/.ansible/tmp/ansible-tmp-1471264096.55-66433255124009/command
<192.168.5.16> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<192.168.5.16> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<192.168.5.16> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<192.168.5.16> SSH: PlayContext set ssh_common_args: ()
<192.168.5.16> SSH: PlayContext set sftp_extra_args: ()
<192.168.5.16> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r)
<192.168.5.16> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.5.16]'
192.168.5.16 | 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
}
求解
2016-08-15 16:17 举报
已邀请:
0

乐橙306

赞同来自:

本帖最后由 乐橙306 于 2016-8-15 18:07 编辑

可能原因
1.秘钥设置有问题
2.配置文件ansible.cfg  hosts有问题

秘钥登陆设置  
[root@aliyun-63 .ssh]# ssh-keygen
[root@aliyun-63 .ssh]# ssh-agent
[root@aliyun-63 .ssh]# ssh-copy-id  -i id_rsa.pub   root@192.168.5.16   (截图)
[root@aliyun-63 .ssh]# ansible 192.168.5.16 -m shell -a 'w' -vvvvv    (截图)
[root@aliyun-63 .ssh]# ssh  root@192.168.5.16   (截图)
[root@aliyun-63 .ssh]#cat  /etc/ansible/ansible.cfg  (截图)
[root@aliyun-63 .ssh]#cat  /etc/ansible/hosts  
0

cj2017

赞同来自:

乐橙306 发表于 2016-8-15 18:02
可能原因
1.秘钥设置有问题
2.配置文件ansible.cfg  hosts有问题

谢谢师兄

是/etc/ansible/ansible.cfg的问题
安装完成之后,没有修改过这个文件

解决方法:

把#scp_if_ssh = True前面的#去掉就可以了

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: