简体   繁体   English

我可以ssh很好,但ansible说“没有路由主持人”

[英]I can ssh just fine, but ansible says “no route to host”

I wrote a script to run up several vms using vagrant, which I have to then provision with ansible. 我写了一个脚本,使用vagrant运行几个vms,然后我必须使用ansible。 Unfortunately my host is a windows machine, so I thought I could solve the issue by putting all the vms into a vpn and then provision them from another machine in the same vpn. 不幸的是我的主机是一台Windows机器,所以我认为我可以通过将所有vms放入vpn然后从同一个vpn中的另一台机器配置它来解决问题。

In theory, it works... I can ssh into the other machines without trouble. 从理论上讲,它可以工作......我可以毫不费力地进入其他机器。 But when I run my ansible playbook, ansible fails. 但是当我运行我的ansible playbook时,ansible失败了。

At first I got the message " ssh: connect to host 10.1.2.100 [10.1.2.100] port 22: No route to host " when running ansible with -vvvv 起初我用-vvvv运行-vvvv时收到消息“ ssh: connect to host 10.1.2.100 [10.1.2.100] port 22: No route to host

This was in the evening, and I was very tired, and this error didn't recur the following morning. 这是在晚上,我很累,这个错误没有在第二天早上重现。 Not sure if it's got something to do with the vm I'm doing deployment from being rebooted in the meantime, or the receiving machine being destroyed and uped completely since then. 不知道是否与vm有关,我正在进行部署,同时重新启动,或者接收机器从那时起被彻底销毁和使用。 In any case, the problem has not gone away. 无论如何,问题并没有消失。

results now, after recreating both vms: 结果现在,重新创建两个vms后:

# ansible-playbook -i vms -k -u vagrant vms.yml -vvvv

result:

<10.1.2.100> ESTABLISH SSH CONNECTION FOR USER: vagrant <10.1.2.100>
SSH: EXEC sshpass -d14 ssh -C -vvv -o ServerAliveInterval=50 -o
User=vagrant -o ConnectTimeout=10 -tt 10.1.2.100 '( umask 22 && mkdir
-p "$( echo $HOME/.ansible/tmp/ansible-tmp-1455781388.36-25193904947084 )" && echo
"$( echo $HOME/.ansible/tmp/ansible-tmp-1455781388.36-25193904947084
)" )' fatal: [10.1.2.100]: FAILED! => {"failed": true, "msg": "ERROR!
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."}

So far so clear. 到目前为止这么清楚。 I ssh into the other instance to add it to the known hosts. 我ssh到另一个实例中将它添加到已知主机。 This works without any trouble. 这没有任何麻烦。

Back to ansible, I try the same command again. 回到ansible,我再次尝试相同的命令。 The result now is: 结果现在是:

<10.1.2.100> ESTABLISH SSH CONNECTION FOR USER: vagrant <10.1.2.100>
SSH: EXEC sshpass -d14 ssh -C -vvv -o ServerAliveInterval=50 -o
StrictHostKeyChecking=no -o User=vagrant -o ConnectTimeout=10 -tt
10.1.2.100 '( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1455782149.99-271768166468916 )" &&
echo "$( echo
$HOME/.ansible/tmp/ansible-tmp-1455782149.99-271768166468916 )" )'
<10.1.2.100> PUT /tmp/tmpXQKa8Z TO
/home/vagrant/.ansible/tmp/ansible-tmp-1455782149.99-271768166468916/setup
<10.1.2.100> SSH: EXEC sshpass -d14 sftp -b - -C -vvv -o
ServerAliveInterval=50 -o StrictHostKeyChecking=no -o User=vagrant -o
ConnectTimeout=10 '[10.1.2.100]' fatal: [10.1.2.100]: UNREACHABLE! =>
{"changed": false, "msg": "ERROR! SSH Error: data could not be sent to
the remote host. Make sure this host can be reached over ssh",
"unreachable": true}

Well, I made sure the host was reachable by ssh, thank you very much! 好吧,我确保ssh可以访问主机,非常感谢你! Ansible still can't get through, and I'm about to get a brain tumor from thinking of things that might be the problem. Ansible仍然无法通过,我即将通过思考可能存在问题的事情来治疗脑肿瘤。

Any suggestions what might be the problem? 有什么建议可能是什么问题?

This issue was reported here, with some workarounds: https://github.com/ansible/ansible/issues/15321 这里报告了这个问题,有一些解决方法: https//github.com/ansible/ansible/issues/15321

The consensus seems to be either to a. 共识似乎要么是a。 use ansible_password or b. 使用ansible_password或b。 use -u username in the connection parameters. 在连接参数中使用-u username However, any number of things can disrupt an SSH connection in ways that make it look "unreachable" to higher level apps, so I recommend going through each of the steps outlined in that ticket. 但是,任何数量的东西都可能破坏SSH连接的方式使其看起来“无法访问”更高级别的应用程序,因此我建议您完成该故障单中列出的每个步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM