ansible behavior to specific sudo commands on managed nodes

后端 未结 1 1715
梦谈多话
梦谈多话 2020-12-20 02:17

Here to discuss the ansible behavior when user at managed nodes is given sudo privileges to specific commands.

I have sudo privileges on remote managed host [rm-hos

相关标签:
1条回答
  • 2020-12-20 02:39

    The short answer is you can't. The way ansible works is by executing python scripts in the remote host (except for the raw, command and shell modules). See the docs.

    The file module executes this script with a long line of parameters. But ansible will first become the required user, in this case root by running sudo -H -S -n -u root /bin/sh in the remote ssh session (please bear in mind that this command might be slightly different in your case).

    Once the user logged remotely has become the root user, Ansible will upload and execute the file.py script.

    It looks like in your case, you'll need to revert to use the raw, command or shell in the cases you need to run the privileged commands.

    To understand this a bit better and see the detail and order of the commands being executed, run ansible-playbook with the parameter -vvvv.

    0 讨论(0)
提交回复
热议问题