0
votes

I have 3 instance groups (eg: AA, BB, CC) and one single inventory of hosts called INVENTORY_A. There is a host_var set for all hosts called HOST_GROUP and the value can be AA, BB or CC.

I want to make sure the job is executed on the respective instance group based on the hosts HOST_GROUP var.

eg: if a host HOST1 in INVENTORY_A has HOST_GROUP value 'BB', then the job must be executed via instance group BB.

Note: all 3 instance groups will be assigned to the inventory INVENTORY_A by default. Also the single inventory is due to technical requirement and cannot be split into 3

Why don't you simly create the groups in your inventory ? What is the point of reinventing the wheel by assigning a host var containing the group name ? I might as well be missing something because you question is not really clear. Can you add an example inventory and an example playbook showing what you intend to do exactly ?Zeitounator
@Zeitounator I was talking about ansible tower instance groups, not ansible groups. both are different. Instance groups are execution environments and i want to dictate the execution of playbooks in Ansible Tower via a specific instance group if the condition is met. (docs.ansible.com/ansible-tower/latest/html/userguide/…)Vijesh Kk
we can choose 1 or more instance groups for a template or inventory in Tower, and if its only 1 instance group selected, then execution of playbook happens via that instance group nodes only. But if you choose multiple instance group for a template or inventory, tower automatically selects an instance group node to execute the playbook on client server. What i am looking for is to assign the job execution to certain instance group based on certain conditions (eg: host variable value), instead of tower choosing the instance group node automaticallyVijesh Kk