linux – Ansible adhoc命令用sudo执行

前端之家收集整理的这篇文章主要介绍了linux – Ansible adhoc命令用sudo执行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要执行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应该可以工作.

Become (Privilege Escalation)

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.

原文链接:https://www.f2er.com/linux/396644.html

猜你在找的Linux相关文章