Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How does sudo work in ansible?
Good day, colleagues, please tell me how sudo works in ansible and what is its difference, if I use sudo directly in the console, I
execute in the console [[email protected] opt]$ sudo mkdir /opt/test
It runs successfully, but when using the command directly with ansible:
[[email protected] opt]$ ansible servers -m file -a "dest=/opt/test mode=755" -k -u user -b
"module_stdout": "Sorry, user user is not allowed to execute '/bin/sh -c echo BECOME-SUCCESS-qvlcsrrsgixvikeamiollrbbnyxljoxl
sudo -l
(ALL) NOPASSWD: ALL, !/bin/sh, !/bin/tcsh, !/bin/csh, !/bin/zsh, !/bin/ksh, !/bin/bash, !/usr/bin/sudo, !/bin/su, !/usr/bin/mc
(root) NOPASSWD: ALL
(root) NOPASSWD: ALL, !/bin/sh, !/bin/tcsh, !/bin/csh, !/bin/zsh, !/bin/ksh, !/bin/bash, !/usr/bin/sudo, !/bin/su, !/usr/bin/mc, !/usr/bin/chattr, !/usr/bin/screen, !/usr/bin/tmux
Answer the question
In order to leave comments, you need to log in
Before running your command, ansible checks that sudo actually works. And this test fails. Matter does not reach mkdir at all.
It is better to throw ansible ssh key from under root.
You go into ubuntu, do su - or sudo -s become root and shove the ansible key. There will be less headaches.
You can disable sudo in ansible and run as that user.
Or enable sudo, but give this user sudo rights.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question