From 5b431f0f7f932293362a01703673ee05d0a5bd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Thu, 19 Aug 2021 09:37:46 +0000 Subject: [PATCH] Allow setting any_errors_fatal true for gather-facts 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). Change-Id: I7a74b937ded0b9da0621cf413f3a5d0d13a2cd68 Partial-Bug: #1833737 --- ansible/gather-facts.yml | 2 ++ ansible/group_vars/all.yml | 8 ++++++++ etc/kolla/globals.yml | 8 ++++++++ .../notes/facts-any-errors-fatal-44cae85bc7e225d7.yaml | 10 ++++++++++ tests/templates/globals-default.j2 | 4 ++++ 5 files changed, 32 insertions(+) create mode 100644 releasenotes/notes/facts-any-errors-fatal-44cae85bc7e225d7.yaml 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 faa0fa661c..2e793885ea 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 45ee9c10b6..7edd6efab2 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 c71bbff2c8..2e696e734e 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 %}