Bug 2187967 - API and WebUI provides different results for Hostgroup Ansible roles association
Summary: API and WebUI provides different results for Hostgroup Ansible roles association
Keywords:
Status: VERIFIED
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Ansible
Version: 6.12.3
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.14.0
Assignee: satellite6-bugs
QA Contact: addubey
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-04-19 09:37 UTC by Pavel Moravec
Modified: 2023-08-09 06:57 UTC (History)
6 users (show)

Fixed In Version: rubygem-foreman_ansible-12.0.5
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 36568 0 Normal Ready For Testing Hostgroup API controller also returns roles assigned to hosts in a host group 2023-07-05 01:57:18 UTC
Red Hat Issue Tracker SAT-18630 0 None None None 2023-06-27 01:25:41 UTC
Red Hat Knowledge Base (Solution) 7008748 0 None None None 2023-04-20 10:38:14 UTC

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.


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