2020-10-11 15:50:47 +00:00
|
|
|
---
|
|
|
|
- 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 -%}
|
2021-01-07 18:50:53 +00:00
|
|
|
{%- if no_proxy_exclude_workers | default(false) -%}
|
2021-03-24 00:26:05 +00:00
|
|
|
{% set cluster_or_master = 'kube_control_plane' %}
|
2021-01-07 18:50:53 +00:00
|
|
|
{%- else -%}
|
2021-04-29 12:20:50 +00:00
|
|
|
{% set cluster_or_master = 'k8s_cluster' %}
|
2021-01-07 18:50:53 +00:00
|
|
|
{%- endif -%}
|
2021-04-29 12:20:50 +00:00
|
|
|
{%- for item in (groups[cluster_or_master] + groups['etcd']|default([]) + groups['calico_rr']|default([]))|unique -%}
|
2020-10-11 15:50:47 +00:00
|
|
|
{{ 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 -%}
|
2021-01-07 18:50:53 +00:00
|
|
|
127.0.0.1,localhost,{{ kube_service_addresses }},{{ kube_pods_subnet }},svc,svc.{{ dns_domain }}
|
2020-10-11 15:50:47 +00:00
|
|
|
delegate_to: localhost
|
|
|
|
connection: local
|
|
|
|
delegate_facts: yes
|
|
|
|
become: no
|
|
|
|
run_once: yes
|
|
|
|
|
|
|
|
- name: Populates no_proxy to all hosts
|
|
|
|
set_fact:
|
|
|
|
no_proxy: "{{ hostvars.localhost.no_proxy_prepare }}"
|
|
|
|
proxy_env: "{{ proxy_env | combine({
|
|
|
|
'no_proxy': hostvars.localhost.no_proxy_prepare,
|
|
|
|
'NO_PROXY': hostvars.localhost.no_proxy_prepare
|
|
|
|
}) }}"
|