Bug 1967649

Summary: The redhat.satellite.external_usergroup module will always use the name of satellite usergroup in the backend api call instead of id.
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: Ansible CollectionAssignee: Evgeni Golov <egolov>
Status: CLOSED ERRATA QA Contact: Vladimír Sedmík <vsedmik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.9.0CC: ahumbe, egolov, vsedmik, zhunting
Target Milestone: 6.10.0Keywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: ansible-collection-redhat-satellite-2.1.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-16 14:11:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sayan Das 2021-06-03 14:22:24 UTC
Description of problem:

When using redhat.satellite.external_usergroup module to map an AD usergroup with Satellite usergroup, it calls for following API  --> GET /api/usergroups/:usergroup_id/external_usergroups 

To have that API properly working ":usergroup_id" should be the usergroup ID of satellite but instead the module always use the name of the group instead of ID.


Version-Release number of selected component (if applicable):

Satellite 6.9

Satellite Ansible collection 


How reproducible:

Always


Steps to Reproduce:
1. Build a Satellite 6.9

2. Create a usergroup by name "043-enterprise systems" in Satellite and Create an AD auth-source by name "AD-RedHat". Consider that there is a "043-enterprise systems" group present in AD which we want to map with satellite usergroup "043-enterprise systems" 

3. Write a play to use "redhat.satellite.external_usergroup" to map "043-enterprise systems" group present in AD with satellite usergroup "043-enterprise systems" 

4. Check /var/log/foreman/production.log in satellite during the playbook execution


Actual results:

Step 3 error:
~~
  ansible_loop_var: item
  error:
    message: Resource external_usergroup not found by id ''
  item:
    name: 043-enterprise systems
    usergroup: 043-enterprise systems
  msg: 'Failed to list resource: HTTPError: 404 Client Error: Not Found'

~~


Step 4 logs from satellite shows how the API is used:
~~
2021-06-03T19:06:14 [I|app|7a0d9e55] Started GET "/api/usergroups/043-enterprise%20systems/external_usergroups" for 10.74.130.249 at 2021-06-03 19:06:14 +0530
2021-06-03T19:06:14 [I|app|7a0d9e55] Processing by Api::V2::ExternalUsergroupsController#index as JSON
2021-06-03T19:06:14 [I|app|7a0d9e55]   Parameters: {"apiv"=>"v2", "usergroup_id"=>"043-enterprise systems"}
2021-06-03T19:06:14 [I|app|7a0d9e55]   Rendering api/v2/errors/not_found.json.rabl within api/v2/layouts/error_layout
~~


Expected results:

Step 3 should be successful and use the ID of the group instead of the name in the API call.


Additional info:

The patch https://gist.github.com/evgeni/8102eef7e1b53bc4a17d3d653f538378 for the redhat.satellite.external_usergroup , fixes this issue.

Comment 5 errata-xmlrpc 2021-11-16 14:11:38 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 (Moderate: Satellite 6.10 Release), 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-2021:4702