You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.6 KiB

  1. ---
  2. - name: Set no_proxy to all assigned cluster IPs and hostnames
  3. set_fact:
  4. # noqa: jinja[spacing]
  5. no_proxy_prepare: >-
  6. {%- if loadbalancer_apiserver is defined -%}
  7. {{ apiserver_loadbalancer_domain_name | default('') }},
  8. {{ loadbalancer_apiserver.address | default('') }},
  9. {%- endif -%}
  10. {%- if no_proxy_exclude_workers | default(false) -%}
  11. {% set cluster_or_master = 'kube_control_plane' %}
  12. {%- else -%}
  13. {% set cluster_or_master = 'k8s_cluster' %}
  14. {%- endif -%}
  15. {%- for item in (groups[cluster_or_master] + groups['etcd'] | default([]) + groups['calico_rr'] | default([])) | unique -%}
  16. {{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(fallback_ips[item])) }},
  17. {%- if item != hostvars[item].get('ansible_hostname', '') -%}
  18. {{ hostvars[item]['ansible_hostname'] }},
  19. {{ hostvars[item]['ansible_hostname'] }}.{{ dns_domain }},
  20. {%- endif -%}
  21. {{ item }},{{ item }}.{{ dns_domain }},
  22. {%- endfor -%}
  23. {%- if additional_no_proxy is defined -%}
  24. {{ additional_no_proxy }},
  25. {%- endif -%}
  26. 127.0.0.1,localhost,{{ kube_service_addresses }},{{ kube_pods_subnet }},svc,svc.{{ dns_domain }}
  27. delegate_to: localhost
  28. connection: local
  29. delegate_facts: yes
  30. become: no
  31. run_once: yes
  32. - name: Populates no_proxy to all hosts
  33. set_fact:
  34. no_proxy: "{{ hostvars.localhost.no_proxy_prepare }}"
  35. # noqa: jinja[spacing]
  36. proxy_env: "{{ proxy_env | combine({
  37. 'no_proxy': hostvars.localhost.no_proxy_prepare,
  38. 'NO_PROXY': hostvars.localhost.no_proxy_prepare
  39. }) }}"