mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-01-08 14:32:09 -03:30
- invoke setup module only once to gather ipv4 and ipv6 addresses - eliminate remaining use of `fallback_ip` and `fallback_ip6`, allowing us to define (with `set_fact` all the "computed" IPs variable in one go, since there is no longer a dependency between them.
42 lines
1.5 KiB
YAML
42 lines
1.5 KiB
YAML
---
|
|
- name: Set facts variables
|
|
tags:
|
|
- always
|
|
block:
|
|
- name: Gather node IPs
|
|
setup:
|
|
gather_subset: '!all,!min,network'
|
|
filter: "ansible_default_ip*"
|
|
when: ansible_default_ipv4 is not defined or ansible_default_ipv6 is not defined
|
|
ignore_unreachable: true
|
|
|
|
- name: Set computed IPs varables
|
|
vars:
|
|
fallback_ip: "{{ ansible_default_ipv4.address | d('127.0.0.1') }}"
|
|
fallback_ip6: "{{ ansible_default_ipv6.address | d('::1') }}"
|
|
# Set 127.0.0.1 as fallback IP if we do not have host facts for host
|
|
# ansible_default_ipv4 isn't what you think.
|
|
_ipv4: "{{ ip | default(fallback_ip) }}"
|
|
_access_ipv4: "{{ access_ip | default(_ipv4) }}"
|
|
_ipv6: "{{ ip6 | default(fallback_ip6) }}"
|
|
_access_ipv6: "{{ access_ip6 | default(_ipv6) }}"
|
|
_access_ips:
|
|
- "{{ _access_ipv4 if ipv4_stack }}"
|
|
- "{{ _access_ipv6 if ipv6_stack }}"
|
|
_ips:
|
|
- "{{ _ipv4 if ipv4_stack }}"
|
|
- "{{ _ipv6 if ipv6_stack }}"
|
|
set_fact:
|
|
cacheable: true
|
|
main_access_ip: "{{ _access_ipv4 if ipv4_stack else _access_ipv6 }}"
|
|
main_ip: "{{ _ipv4 if ipv4_stack else _ipv6 }}"
|
|
# Mixed IPs - for dualstack
|
|
main_access_ips: "{{ _access_ips | select }}"
|
|
main_ips: "{{ _ips | select }}"
|
|
|
|
- name: Set no_proxy
|
|
import_tasks: no_proxy.yml
|
|
when:
|
|
- http_proxy is defined or https_proxy is defined
|
|
- no_proxy is not defined
|