Bug 1728612 - Include Ansible become_method or make it inherit from rex settings
Summary: Include Ansible become_method or make it inherit from rex settings
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Ansible
Version: 6.5.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: 6.7.0
Assignee: Nagoor Shaik
QA Contact: Lukas Pramuk
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-10 09:14 UTC by Kenny Tordeurs
Modified: 2020-04-14 13:25 UTC (History)
10 users (show)

Fixed In Version: tfm-rubygem-foreman_ansible-3.0.8.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-14 13:24:51 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 26850 Normal Closed Ansible become_method doesn't inherit the settings from REX settings 2020-10-26 14:48:52 UTC
Red Hat Knowledge Base (Solution) 4276731 None None None 2019-07-10 09:31:24 UTC
Red Hat Product Errata RHSA-2020:1454 None None None 2020-04-14 13:25:03 UTC

Description Kenny Tordeurs 2019-07-10 09:14:32 UTC
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:

Comment 4 Bryan Kearney 2019-08-08 12:07:06 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26850 has been resolved.

Comment 5 Lukas Pramuk 2019-10-07 16:41:03 UTC
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

Comment 6 Patrick Creech 2019-10-07 17:48:39 UTC
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.

Comment 8 Lukas Pramuk 2020-02-04 13:54:15 UTC
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

Comment 13 errata-xmlrpc 2020-04-14 13:24:51 UTC
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


Note You need to log in before you can comment on or make changes to this bug.