Bug 2164400

Summary: [RFE] Add functionality in API (to match Hammer) to Add/Delete a single Ansible role to Hostgroup without defining every role.
Product: Red Hat Satellite Reporter: mark yarborough <myarboro>
Component: AnsibleAssignee: Oleh Fedorenko <ofedoren>
Status: VERIFIED --- QA Contact: Gaurav Talreja <gtalreja>
Severity: medium Docs Contact: Adam Lazik <alazik>
Priority: unspecified    
Version: 6.9.7CC: alazik, apatel, aruzicka, bangelic, gtalreja, inecas, kgaikwad, lstejska, momran, nalfassi, oezr, ofedoren, pcreech, rabajaj, rkarimpa, rlavi
Target Milestone: 6.14.0Keywords: EasyFix, FutureFeature, Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: rubygem-foreman_ansible-12.0.3 Doc Type: Enhancement
Doc Text:
.You can now add or remove single Ansible role to host or host group through API You can use the new API endpoints to manage Ansible roles on hosts or host groups. To add a role, use the PUT HTTP method. To remove a role, use the DELETE HTTP method. * To manage Ansible roles of a host, use `api/v2/hosts/:id/ansible_roles/:ansible_role_id`. * To manage ansible roles of a host group, use `api/v2/hostgroups/:id/ansible_roles/:ansible_role_id`. Replace `:id` with the ID of your host or host group and `:ansible_role_id` with the ID of the Ansible role that you wish to add or remove.
Story Points: ---
Clone Of: 2029402 Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2029402    
Bug Blocks:    

Comment 2 Oleh Fedorenko 2023-01-27 14:13:52 UTC
Created redmine issue https://projects.theforeman.org/issues/36015 from this bug

Comment 3 Bryan Kearney 2023-01-27 16:03:39 UTC
Upstream bug assigned to ofedoren

Comment 4 Bryan Kearney 2023-01-27 16:03:41 UTC
Upstream bug assigned to ofedoren

Comment 6 Bryan Kearney 2023-05-08 16:04:04 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/36015 has been resolved.

Comment 13 Gaurav Talreja 2023-05-31 19:32:14 UTC
Verified.

Tested on Satellite 6.14.0 Snap 1.0
Version: rubygem-foreman_ansible-12.0.3-1.el8sat.noarch

Steps:
1. Create a Host/HostGroup
2. Import/Sync ansible_roles, and assign a few roles to Host/HostGroup
3. For add and remove ansible_roles for the HostGroup endpoints run "PUT /api/hostgroups/:id/ansible_roles/:ansible_role_id" and "DELETE /api/hostgroups/:id/ansible_roles/:ansible_role_id",
And for add and remove ansible_roles to Host endpoints run "PUT /api/hosts/:id/ansible_roles/:ansible_role_id" and "DELETE /api/hosts/:id/ansible_roles/:ansible_role_id"

Observation:
Add and remove API endpoints works fine for adding and removing single ansible_role with :ansible_role_id to Host/HostGroup.