Hi.
I have situation like this:
- Playbook that is running on hosts A, B, C.
- Each of them have some other hosts under (A → a1 and a2, B → b1 and b2, C → c1 and c2).
- I have groups defined that a1, a2, b1, b2, c1 and c2 are in group GROUPX.
- I have group_vars directory in inventory directory with file for GROUPX (with some variable, that have different value than in “all” group file).
- So in sequence of tasks I have include_role with delegate_to with_items:
- name: “RUN CHILDREN ONE BY ONE”
include_role:
name: ‘MyRole’
delegate_facts: True
delegate_to: “{{host_item}}”
with_items: “{{ children }}”
loop_control:
loop_var: host_item
The problem is, that when I run this… MyRole is run on a1, a2… but group_vars are not set from GROUPX file.
To set them as in GROUPX file… I need to add A, B and C to GROUPX (but I don’t want to).
Is there any magic directive to use group_vars in role from host that is used in delegate_to instruction?
Or maybe I should use something else than delegate_to?
I can’t just use “hosts:” because I am already in hosts running free strategy.
What I am exactly running is:
Run free strategy on A, B, C
On each of them run serial strategy on hosts that are children of current host.
So we have:
A with children a1, a2, a3…
B with b1, b2, b3…
And so on… and you need to run something on all small hosts… with rules:
You CAN NOT run aN and aM in the same time (so only one “ax” host in one time, the same for b, c and so on).
You CAN run “aN” in the same time that “bM” and “cP” and so on (so a1, b1, c2, d5, e2 can run in parallel).
And I can of course run them all in sequence… but I need to run it as fast as possible.
That’s why I am running A, B, C… in parallel. And for each of them running children in sequence.
Maybe there is a way to get it in some different way?