kayobe/ansible/roles/gather-facts-delegated/tasks/main.yml
Matt Crees 498de81efe Fix: configure etc-hosts for overcloud group
Change the etc-hosts role to run on the overcloud group, as using
``ansible_play_hosts_all`` would exclude hosts when running with a
limit.

Also change the gather-facts-delegated role to run on the overcloud
group. The delegated task needs to be included separately as the hostvar
``ansible_host`` cannot be set dynamically based on a loop item in one
task. We loop over the batch indices here so that the tasks are included
in parallel, rather than in series.

Closes-Bug: #2051714

Change-Id: I0465eafa9e4ff37c96064ea8395f0bd461035b40
2024-03-01 15:18:33 +00:00

11 lines
528 B
YAML

---
- name: Gather facts for all hosts (if using --limit)
include_tasks: gather-facts-delegated.yml
vars:
delegated_host: "{{ gather_facts_delegated_delegate_hosts[item | int] }}"
# Loop over the index into each host's batch, so tasks are not all included serially.
with_sequence: start=0 end="{{ gather_facts_delegated_delegate_hosts | length | int - 1 }}"
when:
- item | int < gather_facts_delegated_delegate_hosts | length
- not hostvars[gather_facts_delegated_delegate_hosts[item | int]].ansible_facts