ansible部署時的報錯處理

錯誤1:Missing sudo password

rhel7_node2.westos.com | FAILED! => {
“msg”: “Missing sudo password”
}

  • 回答:

Add a file to the /etc/sudoers.d directory on the target machine called postgres with the following contents:

postgres ALL=(ALL) NOPASSWD:ALL

This ensures that the postgres user (provided you are using that as your sudo user) will not be asked for a password when it attempts sudo commands.

If you are using a different user to connect to the target machine, then you’ll have to amend the above to give the NOPASSWD permission to that user instead.

錯誤2:Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n

192.168.43.10 | UNREACHABLE! => {

“changed”: false,

“msg”: “Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n”,

“unreachable”: true

}

  • 回答:

1:管理節點生成SSH-KEY

ssh-keygen

成功後在~/.ssh/路徑下將生成ssh密鑰文件:id_rsa及id_rsa.pub

2:添加目標節點的SSH認證信息

ssh-copy-id root@目標主機IP

這裏root是在目標節點上登錄的用戶,@符號後面接目標節點IP即可。

添加認證信息後,目標節點主機的~/.ssh/目錄下將會出現一個authorized_keys文件,裏面包含了ansible管理節點的公鑰信息,可以檢查一下是否存在。

3:在確定目標主機的SSH認證信息都已正確添加且目標主機的~/.ssh/目錄都存在管理節點的公鑰信息後,再執行之前出錯的ansible ping指令:

#ansible -m ping all

192.168.43.10 | SUCCESS => {

“changed”: false,

“ping”: “pong”

}

192.168.43.11 | SUCCESS => {

“changed”: false,

“ping”: “pong”

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章