Description of problem: Currently Ansible always uses sudo become_method instead of using the specified 'Effective User Method' it does inherit other settings like 'ssh user' and 'ssh password' so one would expect it would also do this for the become_method. Version-Release number of selected component (if applicable): Satellite 6.5 How reproducible: 100% Steps to Reproduce: 1. Administer -> Settings -> Remote execution settings -> Effective User Method -> su 2. Run ansible playbook 3. Will default to sudo method Actual results: ~~~ Jul 10 08:44:38 ktordeur-test-ansible sshd[24644]: Accepted password for local from 192.168.140.2 port 44284 ssh2 Jul 10 08:44:38 ktordeur-test-ansible sshd[24644]: pam_unix(sshd:session): session opened for user local by (uid=0) Jul 10 08:44:39 ktordeur-test-ansible unix_chkpwd[24730]: password check failed for user (local) Jul 10 08:44:39 ktordeur-test-ansible sudo: pam_unix(sudo:auth): authentication failure; logname=local uid=1000 euid=0 tty=/dev/pts/1 ruser=local rhost= user=local Jul 10 08:44:41 ktordeur-test-ansible sudo: pam_unix(sudo:auth): conversation failed Jul 10 08:44:41 ktordeur-test-ansible sudo: pam_unix(sudo:auth): auth could not identify password for [local] Jul 10 08:44:44 ktordeur-test-ansible sudo: local : user NOT in sudoers ; TTY=pts/1 ; PWD=/home/local ; USER=root ; COMMAND=/bin/sh -c echo BECOME-SUCCESS-nxajxxxwohzbndgcgikajxfdvpmaqeov; /usr/bin/python /home/local/.ansible/tmp/ansible-tmp-1562748279.11-12389537057591/setup.py ~~~ Expected results: Use the su method Additional info:
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26850 has been resolved.
FailedQA. @Satellite 6.6.0 Snap22 tfm-rubygem-foreman_ansible-3.0.7.1-1.el7sat.noarch # find / -path *app/services/foreman_ansible/inventory_creator.rb /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.7.1/app/services/foreman_ansible/inventory_creator.rb # grep ansible_become_method /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-3.0.7.1/app/services/foreman_ansible/inventory_creator.rb <empty> >>> the fix is not present
looking over the v3.0.7 tag in foreman_ansible, I do not see the attached fix. It appears it did not make it into that release.
VERIFIED. @satellite-6.7.0-5.beta.el7sat.noarch tfm-rubygem-foreman_ansible-4.0.3-1.el7sat.noarch by the following manual reproducer: 1. Run Ansible Command job with following command: ps -f $(ps -f $(ps -f $(ps -f $$ | awk 'NR>1{print $3}') | awk 'NR>1{print $3}') | awk 'NR>1{print $3}') 2. Check the output of the job "stdout_lines": [ "UID PID PPID C STIME TTY STAT TIME CMD", "root 23891 23876 1 13:09 pts/1 S+ 0:00 sudo -H -S -p [sudo via ansible, key=bjewyccppqwazaqhkapkmopxvnrnrdea] password: -u test /bin/sh -c echo BECOME-SUCCESS-bjewyccppqwazaqhkapkmopxvnrnrdea ; /usr/bin/python /var/tmp/ansible-tmp-1580407876.01-46452950106097/AnsiballZ_command.py" ] >>> by default "sudo" method is used 3. Change the method to "su" in the settings: Administer -> Settings -> Remote execution settings -> Effective User Method -> su 4. Run Ansible Command job with the same command: ps -f $(ps -f $(ps -f $(ps -f $$ | awk 'NR>1{print $3}') | awk 'NR>1{print $3}') | awk 'NR>1{print $3}') 5. Check the output of the job "stdout_lines": [ "UID PID PPID C STIME TTY STAT TIME CMD", "root 23579 23564 1 13:09 pts/1 S+ 0:00 su test -c /bin/sh -c 'echo BECOME-SUCCESS-rkdzercgvekzoxetgbxnyqwajzsgmxih ; /usr/bin/python /var/tmp/ansible-tmp-1580407930.12-1211950403156/AnsiballZ_command.py'" ] >>> "su" method is used as Ansible REX now inherits the setting from SSH REX
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2020:1454