我正在尝试在多台服务器上运行ansible角色,但出现错误:
致命的:[192.168.0.10]:无法达到!=> {“已更改”:false,“ msg”:“无法通过ssh连接到主机。”,“无法访问”:true}
我的/ etc / ansible / hosts文件如下所示:
192.168.0.10 ansible_sudo_pass='passphrase' ansible_ssh_user=user
192.168.0.11 ansible_sudo_pass='passphrase' ansible_ssh_user=user
192.168.0.12 ansible_sudo_pass='passphrase' ansible_ssh_user=user
我不知道发生了什么事-一切看起来都很好-我可以通过SSH登录,但无法ping会返回相同的错误。
详细执行的日志:
<192.168.0.10>为用户建立SSH连接:用户<192.168.0.10> SSH:EXEC ssh -C -vvv -o ControlMaster = auto -o ControlPersist = 60s -o KbdInteractiveAuthentication = no -o PreferredAuthentications = gssapi-with-mic, gssapi-keyex,基于主机的公钥-o PasswordAuthentication = no -o User = user -o ConnectTimeout = 10 -o ControlPath = / root / .ansible / cp / ansible-ssh-%h-%p-%r 192.168.0.10' / bin / sh -c'“'”'(umask 22 && mkdir -p“
echo $HOME/.ansible/tmp/ansible-tmp-1463151813.31-156630225033829
” && echo“echo $HOME/.ansible/tmp/ansible-tmp-1463151813.31-156630225033829
”)'“'”“''
你能以某种方式帮助我吗?如果我必须在本地模式(-c本地)下使用ansible,那么它是没有用的。
我尝试删除ansible_sudo_pass和ansible_ssh_user,但这没有帮助。
您需要更改ansible_ssh_pass
as或ssh键,例如,我在清单文件中使用了它:
192.168.33.100 ansible_ssh_pass=vagrant ansible_ssh_user=vagrant
之后,我可以连接到远程主机:
ansible all -i tests -m ping
结果如下:
192.168.33.100 | SUCCESS => {
"changed": false,
"ping": "pong"
}
希望对您有所帮助。
编辑:ansible_ssh_pass
&ansible_ssh_user
不能在最新版本的Ansible中工作。它已更改为ansible_user
&ansible_pass
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句