fact gathering: Group hosts before gathering facts

If not using --limit, each host runs the setup module for itself only.
Hosts should be able to fail at this point and drop out of execution
without affecting others. However, there is a bug that causes us to hit
the --limit code path for an unreachable host and therefore become
subject to its limitations.  These include the use of delegated fact
gathering, and failing the delegated host when the delegating host is
unreachable.

This change fixes the issue by reversing the order of two tasks in the
gather-facts.yml playbook, ensuring that we check the ansible_play_batch
variable before any hosts have had a chance to fail.

Change-Id: I4b1da63e8f0cc2774f1a9ab2e0414746108f7e12
Closes-Bug: #2041859
This commit is contained in:
Mark Goddard 2023-10-30 14:36:48 +00:00
parent 8709db2a25
commit 7f01f47bda

View File

@ -8,17 +8,17 @@
serial: '{{ kolla_serial|default("0") }}'
gather_facts: false
tasks:
- name: Group hosts to determine when using --limit
group_by:
key: "all_using_limit_{{ (ansible_play_batch | length) != (groups['all'] | length) }}"
changed_when: false
- name: Gather facts
setup:
filter: "{{ kolla_ansible_setup_filter }}"
gather_subset: "{{ kolla_ansible_setup_gather_subset }}"
when:
- not ansible_facts
- name: Group hosts to determine when using --limit
group_by:
key: "all_using_limit_{{ (ansible_play_batch | length) != (groups['all'] | length) }}"
changed_when: false
tags: always
# NOTE(pbourke): This case covers deploying subsets of hosts using --limit. The