ansible ad-hoc命令以其他用户身份运行

thi*_*ter 1 ansible

在Ansible记录中,它表示为:

也可以使用--become-user来成为非root用户:$ ansible atlanta -a“ / usr / bin / foo” -u username --become-user otheruser [--ask-become-pass]

但是当我运行此命令时

ansible webservers  -m shell -a "mkdir /tmp/devopstraining" --become-user devops
Run Code Online (Sandbox Code Playgroud)

它的创建目录以root为所有者。如果根据文档,如果此命令以devops用户身份运行,则devops用户应为所创建目录的所有者。

我知道我可以使用文件模块来处理权限,但只是想知道为什么它不能在上述命令中起作用。

Kon*_*rov 5

尝试:

ansible webservers -m shell -a "mkdir /tmp/devopstraining" --become --become-user devops
Run Code Online (Sandbox Code Playgroud)