以非root用户身份运行Ansible命令无效

时间:2020-08-31 17:33:05

标签: ansible

我需要以非root用户身份运行一些Ansible命令(例如“ notme”)。以下临时命令说明了此问题。我可以连接,成为root用户并执行命令,但是如果我告诉Ansible成为root用户的“ notme”用户,它将失败。

[me@master:~]$ ansible test_host -m shell -a "whoami" -b -K
BECOME password:
test_host | CHANGED | rc=0 >>
root
[me@master:~]$ ansible test_host -m shell -a "whoami" -b -K --become-user=notme
BECOME password:
test_host | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "module_stderr": "",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

如果我在交互式外壳中SSH到test_host并运行“ dzdo su-notme”,那么我就可以成为“ notme”用户。不能以root用户身份运行命令。我在test_host上具有root用户访问权限,但是其他需要以test_host上的“ notme”用户身份运行Ansible播放的用户没有root用户访问权限,并且他们也无法直接通过SSH作为notme SSH到test_host。他们只有在连接到test_host后才能“ dzdo su-notme”。

要使Ansible以非root用户身份在远程系统上成功运行命令,我需要做什么?

0 个答案:

没有答案