1
我想在本地主機上運行命令,使用ansible_connection=local
,但也可以作爲特定用戶,即ansible_user=my_other_user
。有趣的是,兩個選擇似乎是相互排斥的:Ansible:作爲本地主機上的其他用戶運行
- 隨着
/etc/ansible/hosts
爲localhost ansible_user=my_other_user
ansible localhost -a "whoami" localhost | SUCCESS | rc=0 >> my_other_user
- 隨着
/etc/ansible/hosts
爲localhost ansible_user=my_other_user ansible_connection=local
ansible localhost -a "whoami" localhost | SUCCESS | rc=0 >> myself
這是錯誤還是功能?
如何使用配置Ansible的清單使用my_other_user登錄到本地主機,但不需要ssh?
編輯:這應該永遠不會使用sudo通過本地用戶myself
。用戶myself
和my_other_user
的密碼是不同的,Ansible不知道密碼myself
。
EDIT2:改變到方法su
(即localhost ansible_connection=local ansible_become_user=my_other_user ansible_become_method=su ansible_become=true
)不不工作,因爲它然後不可能不知道根密碼作爲root運行命令。
這種解決方案並沒有爲我工作,但我需要Ansible使用sudo密碼'WWW-data'。編輯的問題更精確。 – Kalsan