Bug 2187967

Summary: API and WebUI provides different results for Hostgroup Ansible roles association
Product: Red Hat Satellite Reporter: Pavel Moravec <pmoravec>
Component: Ansible - Configuration ManagementAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: addubey
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.12.3CC: addubey, amasolov, bgajjava, ehelms, gtalreja, nalfassi, pcreech, pdwyer
Target Milestone: 6.14.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-foreman_ansible-12.0.5 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-08 14:19:16 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 Pavel Moravec 2023-04-19 09:37:54 UTC
Description of problem:
API query

/api/hostgroups/HOSTGROUPID/ansible_roles

does provide different output that WebUI editing the same HostGroup in some cases. Esp. when:
- an Ansible Role (AR) is *not* associated with the HG (neither with its parents),
- the AR is associated to a Host
- the Host is associated with the HG

Then API call follows https://github.com/theforeman/foreman_ansible/blob/master/app/models/concerns/foreman_ansible/hostgroup_extensions.rb#L37-L43 and adds that AR to its response.

Contrary to that, WebUI uses https://github.com/theforeman/foreman_ansible/blob/master/app/helpers/foreman_ansible/ansible_roles_helper.rb#L38-L49 method that counts with ARs associated to the HG and/or its parents - only.


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


How reproducible:
100%


Steps to Reproduce:
1. Have 2 Ansible Roles, one assigned to a HG, another to a Host
2. Assign the Host to the HostGroup
3. In WebUI, edit the HostGroup -> Ansible Roles tab
4. call /api/hostgroups/HOSTGROUPID/ansible_roles (i.e. "curl -s -u admin:password https://$(hostname -f)/api/hostgroups/1/ansible_roles")


Actual results:
3. shows just the one AG assigned to the HG
4. shows *two* AGs "assigned" to the HG: the right one and also the one assigned "just" to the Host


Expected results:
Align the results - I think API response should be corrected and should not output ARs assigned to Hosts (associated with the HG). Since those AGs are not (directly) associated with the HG.


Additional info:

Comment 2 Bryan Kearney 2023-07-25 16:02:56 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/36568 has been resolved.

Comment 8 errata-xmlrpc 2023-11-08 14:19:16 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 (Important: Satellite 6.14 security and bug fix update), 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-2023:6818