【发布时间】:2018-01-26 02:52:14
【问题描述】:
我想在本地主机上运行一个命令,使用ansible_connection=local,但也作为一个特定的用户,即ansible_user=my_other_user。有趣的是,这两个选项似乎是相互排斥的:
-
/etc/ansible/hosts是localhost ansible_user=my_other_useransible localhost -a "whoami" localhost | SUCCESS | rc=0 >> my_other_user
-
/etc/ansible/hosts是localhost ansible_user=my_other_user ansible_connection=localansible localhost -a "whoami" localhost | SUCCESS | rc=0 >> myself
这是错误还是功能?
如何使用配置 Ansible 的 Inventory 以使用 my_other_user 登录 localhost 而无需 ssh?
编辑:这不应该通过本地用户myself 使用 sudo。用户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密码的情况下无法以root身份运行命令。
【问题讨论】:
标签: linux ansible localhost ansible-inventory