Skip to content

Commit

Permalink
streamline ansible_default_ipv4 gathering loop (kubernetes-sigs#9281)
Browse files Browse the repository at this point in the history
  • Loading branch information
rptaylor authored and nolimitkun committed Mar 19, 2023
1 parent 0e3fade commit 3d17b34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
14 changes: 8 additions & 6 deletions roles/kubespray-defaults/tasks/fallback_ips.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 0 additions & 11 deletions roles/kubespray-defaults/tasks/fallback_ips_gather.yml

This file was deleted.

0 comments on commit 3d17b34

Please sign in to comment.