I am currently using Ansible with AWX to deploy our VMs across different hypervisors. While the deployment process is functioning well, I would like to optimize it further. However, I am having difficulty finding the correct API information.
Specifically, I need to know the appropriate endpoint to target groups within an inventory. My goal is to ensure that when a VM is deployed based on its template (Debian or RHEL), it is automatically added to the corresponding group. Currently, all VMs are deployed under the top inventory group (AWX_LINUX), but I would like Debian-based VMs to be categorized under DEBIAN_BASED and Red Hat VMs under RHEL_BASED.
This adjustment will allow the subsequent playbooks to run automatically on the correct systems, rather than having to manually target RHEL and Debian in the workflow, which is causing some delays.
Any guidance on the API endpoint or best practices for achieving this would be greatly appreciated.
Check out the operations/Host/Hosts_hosts_groups_create API POST function. Don’t be misled by the “groups create” name. It’s also used to associate an existing host with an existing group, and to remove (“disassociate”) a host from a group.
I am using a constructed inventory with keyed groups. So a host will have variable like template: rhel or template: debian and from those I automatically create groups.