Bug 1447086

Summary: [Ansible Embedded] - Privilege escalation for playbook does not work
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: AutomateAssignee: Harpreet Kataria <hkataria>
Status: CLOSED ERRATA QA Contact: Dmitry Misharov <dmisharo>
Severity: high Docs Contact:
Priority: high    
Version: 5.8.0CC: akarol, bilwei, cpelland, jfrey, jhardy, mkanoor, obarenbo, saali, simaishi, tfitzger
Target Milestone: GA   
Target Release: 5.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: ansible_embed
Fixed In Version: 5.8.0.13 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1445377 Environment:
Last Closed: 2017-05-31 15:07:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Ansible Target Upstream Version:
Embargoed:
Bug Depends On: 1445377    
Bug Blocks:    
Attachments:
Description Flags
awx
none
error
none
ip none

Comment 2 CFME Bot 2017-05-01 17:03:15 UTC
New commit detected on ManageIQ/manageiq-ui-classic/fine:
https://github.com/ManageIQ/manageiq-ui-classic/commit/3e989229cdf308b93118362d41971f77fdf363b2

commit 3e989229cdf308b93118362d41971f77fdf363b2
Author:     Dan Clarizio <dclarizi>
AuthorDate: Mon May 1 09:19:39 2017 -0700
Commit:     Satoe Imaishi <simaishi>
CommitDate: Mon May 1 13:02:46 2017 -0400

    Merge pull request #1207 from h-kataria/escalate_privilege_option
    
    Added "Escalate Privilege" checkbox
    (cherry picked from commit 4f45c537341088d8f1dfba252f4ae77822998bd8)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1447086

 .../controllers/catalog/catalog_item_form_controller.js   | 15 ++++++++++++++-
 app/controllers/catalog_controller.rb                     |  2 ++
 app/views/catalog/_sandt_tree_show.html.haml              | 10 ++++++++++
 .../angular/_ansible_form_options_angular.html.haml       | 13 ++++++++++++-
 spec/controllers/catalog_controller_spec.rb               | 12 ++++++++----
 .../catalog/catalog_item_form_controller_spec.js          |  1 +
 6 files changed, 47 insertions(+), 6 deletions(-)

Comment 3 CFME Bot 2017-05-01 17:06:04 UTC
New commit detected on ManageIQ/manageiq/fine:
https://github.com/ManageIQ/manageiq/commit/d5db6cd5b2c907327db5343d9c7a3d96e7771a8e

commit d5db6cd5b2c907327db5343d9c7a3d96e7771a8e
Author:     Greg McCullough <gmccullo>
AuthorDate: Fri Apr 28 10:52:58 2017 -0400
Commit:     Satoe Imaishi <simaishi>
CommitDate: Mon May 1 13:00:38 2017 -0400

    Merge pull request #14929 from bzwei/escalate_privilage
    
    Escalate privilege
    (cherry picked from commit 291254e928dd64a3e52caa9a07cb788ab62663c7)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1447086

 app/models/service_template_ansible_playbook.rb       | 5 +++--
 spec/models/service_template_ansible_playbook_spec.rb | 4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

Comment 4 Dmitry Misharov 2017-05-04 07:26:30 UTC
Verified in 5.8.0.13-rc2.20170502165848_0f98658. Privilege escalation works as expected.

Comment 5 Saif Ali 2017-05-05 23:14:10 UTC
Created attachment 1276707 [details]
awx

Comment 6 Saif Ali 2017-05-05 23:14:33 UTC
Created attachment 1276708 [details]
error

Comment 7 Saif Ali 2017-05-05 23:16:11 UTC
I'm still getting the error in fact the machine credential has no effect, and all the job seem to be running as awx user.

5.8.0.13-rc2-20170502165848_0f98658

Comment 8 Bill Wei 2017-05-07 23:06:40 UTC
Saif,
I guess the first screenshot was the case without privilege escalation, and the second screenshot was with the flag on.

This BZ is to enhance our integration with Ansible that at job execution we instruct it to use su command run the job. The screenshot illustrated it is working as designed. The system received the flag and attempted to run su command.

The actual execution failure may be caused by the setup. Please make sure the credential you choose for the playbook meets the requirement, for example you have chosen the correct su/sudo, and user/password.

Comment 9 Saif Ali 2017-05-07 23:44:40 UTC
Bill,
The user has sudo access without password. I notice the playbook fail only when the host is set to localhost. If i use the IP it work fine using the same user.

Comment 10 Saif Ali 2017-05-07 23:45:12 UTC
Created attachment 1276911 [details]
ip

Comment 11 Bill Wei 2017-05-08 01:51:22 UTC
Is the IP of the CFME appliance?

Comment 12 Saif Ali 2017-05-08 13:59:55 UTC
Yes thats appliance IP.

Comment 13 Bill Wei 2017-05-08 18:13:34 UTC
We did some the same test and understand what's going on. When a playbook executes in localhost Tower always logs in as awx and does not allow privilege escalation. This makes sense for security reason. When you use IP tower does not know it is actually localhost therefore it treats the host as a regular machine.

In conclusion privilege escalation works only in non-localhost.

Comment 14 Saif Ali 2017-05-08 18:15:39 UTC
Bill, Thats make sense.

Comment 16 errata-xmlrpc 2017-05-31 15:07:09 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-2017:1367