diff --git a/ansible/gather-facts.yml b/ansible/gather-facts.yml index 0c7c792982..f5247a6ab9 100644 --- a/ansible/gather-facts.yml +++ b/ansible/gather-facts.yml @@ -4,6 +4,7 @@ # building their configurations. - name: Gather facts for all hosts hosts: all + any_errors_fatal: "{{ kolla_ansible_setup_any_errors_fatal | bool }}" serial: '{{ kolla_serial|default("0") }}' gather_facts: false tasks: @@ -28,6 +29,7 @@ # the limit. - name: Gather facts for all hosts (if using --limit) hosts: all_using_limit_True + any_errors_fatal: "{{ kolla_ansible_setup_any_errors_fatal | bool }}" serial: '{{ kolla_serial|default("0") }}' gather_facts: false vars: diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 7831e88cc9..4492e47bd3 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -36,6 +36,14 @@ kolla_ansible_setup_filter: "{{ omit }}" # By default, we do not provide a gather subset. kolla_ansible_setup_gather_subset: "{{ omit }}" +# This variable is used as "any_errors_fatal" setting for the setup (gather +# facts) plays. +# This is useful for weeding out failing hosts early to avoid late failures +# due to missing facts (especially cross-host). +# Do note this still supports host fact caching and it will not affect +# scenarios with all facts cached (as there is no task to fail). +kolla_ansible_setup_any_errors_fatal: false + ################### # Kolla options ################### diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index c436963d22..13accc9f6f 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -24,6 +24,14 @@ # Dummy variable to allow Ansible to accept this file. workaround_ansible_issue_8743: yes +# This variable is used as "any_errors_fatal" setting for the setup (gather +# facts) plays. +# This is useful for weeding out failing hosts early to avoid late failures +# due to missing facts (especially cross-host). +# Do note this still supports host fact caching and it will not affect +# scenarios with all facts cached (as there is no task to fail). +#kolla_ansible_setup_any_errors_fatal: false + ############### # Kolla options ############### diff --git a/releasenotes/notes/facts-any-errors-fatal-44cae85bc7e225d7.yaml b/releasenotes/notes/facts-any-errors-fatal-44cae85bc7e225d7.yaml new file mode 100644 index 0000000000..36c4c2e2f2 --- /dev/null +++ b/releasenotes/notes/facts-any-errors-fatal-44cae85bc7e225d7.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Kolla Ansible now supports failing execution early if fact collection + fails on any of the hosts. This is to avoid late failures due to missing + facts (especially cross-host). + This is possible by setting + ``kolla_ansible_setup_any_errors_fatal: true``. + Do note this still supports host fact caching and it will not affect + scenarios with all facts cached (as there is no task to fail). diff --git a/tests/templates/globals-default.j2 b/tests/templates/globals-default.j2 index 5d8a13a3c9..a2c903a670 100644 --- a/tests/templates/globals-default.j2 +++ b/tests/templates/globals-default.j2 @@ -5,6 +5,10 @@ ansible_python_interpreter: /usr/bin/python3 {% endif %} +# NOTE(yoctozepto): In CI it makes sense to always try to fail +# as early as possible. +kolla_ansible_setup_any_errors_fatal: true + kolla_base_distro: "{{ base_distro }}" # Zed dropped install_type so we have it only on upgrades {% if is_upgrade %}