forked from kubernetes-sigs/kubespray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
assembly fallback_ips and no_proxy var only one time on localhost and… (
kubernetes-sigs#5957) * assembly fallback_ips and no_proxy var only one time on localhost and populate result on all hosts * add tag always, fix ansible lint errors * workaround to mitogen issue mitogen-hq/mitogen#663 * do not gather fact before install python on coreos like distros * try to pass docker molecule test
- Loading branch information
Showing
6 changed files
with
86 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
# 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. | ||
# Thanks https://medium.com/opsops/ansible-default-ipv4-is-not-what-you-think-edb8ab154b10 | ||
|
||
- name: Gather ansible_default_ipv4 from all hosts | ||
include_tasks: fallback_ips_gather.yml | ||
when: hostvars[delegate_host_to_gather_facts].ansible_default_ipv4 is not defined | ||
loop: "{{ groups['all'] }}" | ||
loop_control: | ||
loop_var: delegate_host_to_gather_facts | ||
run_once: yes | ||
|
||
- name: create fallback_ips_base | ||
set_fact: | ||
fallback_ips_base: | | ||
--- | ||
{% for item in (groups['k8s-cluster']|default([]) + groups['etcd']|default([]) + groups['calico-rr']|default([]))|unique %} | ||
{% set found = hostvars[item].get('ansible_default_ipv4') %} | ||
{{ item }}: "{{ found.get('address', '127.0.0.1') }}" | ||
{% endfor %} | ||
delegate_to: localhost | ||
delegate_facts: yes | ||
become: no | ||
run_once: yes | ||
|
||
- name: set fallback_ips | ||
set_fact: | ||
fallback_ips: "{{ hostvars.localhost.fallback_ips_base | from_yaml }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
# 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 }}" | ||
delegate_facts: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: Set no_proxy to all assigned cluster IPs and hostnames | ||
set_fact: | ||
no_proxy_prepare: >- | ||
{%- if loadbalancer_apiserver is defined -%} | ||
{{ apiserver_loadbalancer_domain_name| default('') }}, | ||
{{ loadbalancer_apiserver.address | default('') }}, | ||
{%- endif -%} | ||
{%- for item in (groups['k8s-cluster'] + groups['etcd'] + groups['calico-rr']|default([]))|unique -%} | ||
{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(fallback_ips[item])) }}, | ||
{%- if item != hostvars[item].get('ansible_hostname', '') -%} | ||
{{ hostvars[item]['ansible_hostname'] }}, | ||
{{ hostvars[item]['ansible_hostname'] }}.{{ dns_domain }}, | ||
{%- endif -%} | ||
{{ item }},{{ item }}.{{ dns_domain }}, | ||
{%- endfor -%} | ||
{%- if additional_no_proxy is defined -%} | ||
{{ additional_no_proxy }}, | ||
{%- endif -%} | ||
127.0.0.1,localhost,{{ kube_service_addresses }},{{ kube_pods_subnet }} | ||
delegate_to: localhost | ||
delegate_facts: yes | ||
become: no | ||
run_once: yes | ||
|
||
- name: Populates no_proxy to all hosts | ||
set_fact: | ||
no_proxy: "{{ hostvars.localhost.no_proxy_prepare }}" |