剛開始與Ansible。我配置的主機文件是這樣的:Ansible測試主機失敗
[webserver]
<remote-server-ip> ansible_user=<user> ansible_private_key_file=<full-path-to-private-ssh-key>
當我運行:
ansible all -m ping
我得到:
<remote-server-ip> | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Couldn't read packet: Connection reset by peer\r\n",
"unreachable": true
我沒有問題連接,如果我跑:
ssh -i <full-path-to-private-ssh-key> <user>@<remote-server-ip>
備註:
- SSH密鑰沒有密碼。
- 該項目位於
~/my_project_name
。 - 我也嘗試過使用
ansible_connection=local
,雖然ansible all -m ping
似乎工作,但實際上它所做的只是允許我執行修改Ansible運行的主機的任務。 - ansible.cfg文件尚未修改,但它位於不同的目錄中:
/etc/ansible/ansible.cfg
。
運行'ansible webserver -m ping'時會發生什麼? – harshavmb
@harshavmb - 結果是一樣的 –
你可以運行'ansible all -m ping -vv'嗎?它給出了更詳細的日誌 – harshavmb