From 0ff883afeb6966292d156b04dbd3205b8238b2e2 Mon Sep 17 00:00:00 2001 From: "R. P. Taylor" <1686627+rptaylor@users.noreply.github.com> Date: Thu, 5 Jan 2023 11:59:58 -0800 Subject: [PATCH] streamline ansible_default_ipv4 gathering loop (#9281) --- roles/kubespray-defaults/tasks/fallback_ips.yml | 14 ++++++++------ .../tasks/fallback_ips_gather.yml | 11 ----------- 2 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 roles/kubespray-defaults/tasks/fallback_ips_gather.yml diff --git a/roles/kubespray-defaults/tasks/fallback_ips.yml b/roles/kubespray-defaults/tasks/fallback_ips.yml index acca31c0c..d42faee8f 100644 --- a/roles/kubespray-defaults/tasks/fallback_ips.yml +++ b/roles/kubespray-defaults/tasks/fallback_ips.yml @@ -4,13 +4,15 @@ # Thanks https://medium.com/opsops/ansible-default-ipv4-is-not-what-you-think-edb8ab154b10 - name: Gather ansible_default_ipv4 from all hosts - tags: always - include_tasks: fallback_ips_gather.yml - when: hostvars[delegate_host_to_gather_facts].ansible_default_ipv4 is not defined - loop: "{{ groups['k8s_cluster']|default([]) + groups['etcd']|default([]) + groups['calico_rr']|default([]) }}" - loop_control: - loop_var: delegate_host_to_gather_facts + setup: + gather_subset: '!all,network' + filter: "ansible_default_ipv4" + delegate_to: "{{ item }}" + delegate_facts: yes + when: hostvars[item].ansible_default_ipv4 is not defined + loop: "{{ (groups['k8s_cluster']|default([]) + groups['etcd']|default([]) + groups['calico_rr']|default([])) | unique }}" run_once: yes + tags: always - name: create fallback_ips_base set_fact: diff --git a/roles/kubespray-defaults/tasks/fallback_ips_gather.yml b/roles/kubespray-defaults/tasks/fallback_ips_gather.yml deleted file mode 100644 index 2d2d000d6..000000000 --- a/roles/kubespray-defaults/tasks/fallback_ips_gather.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# include to workaround mitogen issue -# https://github.com/dw/mitogen/issues/663 - -- name: "Gather ansible_default_ipv4 from {{ delegate_host_to_gather_facts }}" - setup: - gather_subset: '!all,network' - filter: "ansible_default_ipv4" - delegate_to: "{{ delegate_host_to_gather_facts }}" - connection: "{{ (delegate_host_to_gather_facts == 'localhost') | ternary('local', omit) }}" - delegate_facts: yes