我需要执行ansible adhoc命令.
$ansible somehost -m command -a "cat /etc/passwd"-u someuser --ask-sudo-pass
我有一个具有sudo权限的用户帐户(someuser).通常我成了根sudo su – .
如何在sudo su中使用adhoc命令 – ?
ansible版本是2.0.0.2
解决方法
对于Ansible 1.9或更高版本,您需要使用–ask-become-pass.对于旧版本–ask-sudo-pass应该可以工作.
Before 1.9 Ansible mostly allowed the use of sudo and a limited use of
su to allow a login/remote user to become a different user and execute
tasks,create resources with the 2nd user’s permissions. As of 1.9
become supersedes the old sudo/su,while still being backwards
compatible. This new system also makes it easier to add other
privilege escalation tools like pbrun (Powerbroker),pfexec,dzdo (Centrify),and others.