我試圖運行在多個服務器上ansible的角色,但我得到一個錯誤:ansible SSH連接失敗
fatal: [192.168.0.10]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": 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> ESTABLISH SSH CONNECTION FOR USER: user <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,hostbased,publickey -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
" )'"'"''
你能幫我不知何故?如果我必須在本地模式下使用ansible(-c local),那麼它是無用的。
我試着刪除ansible_sudo_pass和ansible_ssh_user,但它沒有幫助。
是的!我錯過了ansible_ssh_pass變量。一切都像現在的魅力一樣。非常感謝! – Thomas
根據http://docs.ansible.com/ansible/intro_inventory.html,它應該是'ansible_user'而不是'ansible_ssh_user'。 – Matthias
如果你搜索'ansible_ssh_user',那麼你可以在上面提到的鏈接中找到它,它在1.9中使用,但在合理的2.0版本中,它們已經將其更改爲'ansible_user',但是'ansible_ssh_user'仍然對兩者都有效。 –