0

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

Vijesh Kk
  • 141
  • 2
  • 11
  • 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 Feb 15 '21 at 09:19
  • 2
    @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. (https://docs.ansible.com/ansible-tower/latest/html/userguide/instance_groups.html) – Vijesh Kk Feb 15 '21 at 11:23
  • 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 automatically – Vijesh Kk Feb 15 '21 at 11:37
  • @VijeshKk have you been able to get this to work? – Robbert Mar 22 '22 at 01:47
  • @Robbert unfortunately not. I wanted to hav separate instance nodes for different locations n run the jobs from respective instance nodes based on host location. but now instance node is randomly selected which is really inefficient way. – Vijesh Kk Mar 23 '22 at 02:32

0 Answers0