From edd2868ef6e599c0bc7178f6f2afe22c454faa54 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Mon, 12 Sep 2022 19:20:58 +0100 Subject: [PATCH] tests: Don't rely on facts when setting become They won't be available if the play is first, and hence no facts have been gather in previous play(s), e.g. due to --start-at-task --- .ci/ansible_tests.py | 6 ++++-- .../regression/issue_776__load_plugins_called_twice.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.ci/ansible_tests.py b/.ci/ansible_tests.py index fd0714a7..43d4f4cb 100755 --- a/.ci/ansible_tests.py +++ b/.ci/ansible_tests.py @@ -66,14 +66,16 @@ with ci_lib.Fold('job_setup'): for container in containers ) - for distro, hostnames in distros.items(): + for distro, hostnames in sorted(distros.items(), key=lambda t: t[0]): fp.write('\n[%s]\n' % distro) fp.writelines('%s\n' % name for name in hostnames) - for family, hostnames in families.items(): + for family, hostnames in sorted(families.items(), key=lambda t: t[0]): fp.write('\n[%s]\n' % family) fp.writelines('%s\n' % name for name in hostnames) + fp.write('\n[linux:children]\ntest-targets\n') + ci_lib.dump_file(inventory_path) if not ci_lib.exists_in_path('sshpass'): diff --git a/tests/ansible/regression/issue_776__load_plugins_called_twice.yml b/tests/ansible/regression/issue_776__load_plugins_called_twice.yml index bd57fe12..2eda3944 100755 --- a/tests/ansible/regression/issue_776__load_plugins_called_twice.yml +++ b/tests/ansible/regression/issue_776__load_plugins_called_twice.yml @@ -2,7 +2,7 @@ --- - name: regression/issue_776__load_plugins_called_twice.yml hosts: test-targets - become: "{{ ansible_facts.pkg_mgr not in ['homebrew'] }}" + become: "{{ groups.linux is defined and inventory_hostname in groups.linux }}" gather_facts: yes tags: - issue_776