2016-11-30 21:06:11 +08:00
---
2018-08-20 22:07:27 +08:00
- set_fact :
architecture_groups :
x86_64 : amd64
aarch64 : arm64
- name : ansible_architecture_rename
set_fact :
host_architecture : >-
{%- if ansible_architecture in architecture_groups -%}
{{architecture_groups[ansible_architecture]}}
{%- else -%}
{{ansible_architecture}}
{% endif %}
2018-08-23 22:51:52 +08:00
- name : Force binaries directory for Container Linux by CoreOS
set_fact :
bin_dir : "/opt/bin"
when : ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
tags :
- facts
- name : check if atomic host
stat :
path : /run/ostree-booted
register : ostree
- set_fact :
is_atomic : "{{ ostree.stat.exists }}"
- set_fact :
kube_cert_group : "kube"
when : is_atomic
2016-11-30 21:06:11 +08:00
- name : check resolvconf
shell : which resolvconf
register : resolvconf
2016-12-27 19:38:54 +08:00
failed_when : false
2016-11-30 21:06:11 +08:00
changed_when : false
2017-02-07 02:13:21 +08:00
check_mode : no
2016-11-30 21:06:11 +08:00
- set_fact :
resolvconf : >-
{%- if resolvconf.rc == 0 -%}true{%- else -%}false{%- endif -%}
- set_fact :
2016-11-30 21:06:11 +08:00
bogus_domains : |-
2016-11-30 21:06:11 +08:00
{% for d in [ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([]) -%}
{{dns_domain}}.{{d}}./{{d}}.{{d}}./com.{{d}}./
{%- endfor %}
2018-01-31 05:26:07 +08:00
cloud_resolver : >-
2017-04-20 21:53:01 +08:00
{%- if cloud_provider is defined and cloud_provider == 'gce' -%}
2018-01-31 05:26:07 +08:00
[ '169.254.169.254' ]
2017-04-20 21:53:01 +08:00
{%- elif cloud_provider is defined and cloud_provider == 'aws' -%}
2018-01-31 05:26:07 +08:00
[ '169.254.169.253' ]
2017-04-20 21:53:01 +08:00
{%- else -%}
2018-01-31 05:26:07 +08:00
[ ]
2017-04-20 21:53:01 +08:00
{%- endif -%}
2016-11-30 21:06:11 +08:00
2017-01-19 00:18:47 +08:00
- name : check if kubelet is configured
2016-11-30 21:06:11 +08:00
stat :
2017-01-19 00:18:47 +08:00
path : "{{ kube_config_dir }}/kubelet.env"
register : kubelet_configured
2016-11-30 21:06:11 +08:00
changed_when : false
- name : check if early DNS configuration stage
set_fact :
dns_early : >-
2017-01-19 00:18:47 +08:00
{%- if kubelet_configured.stat.exists -%}false{%- else -%}true{%- endif -%}
2016-11-30 21:06:11 +08:00
- name : target resolv.conf files
set_fact :
resolvconffile : /etc/resolv.conf
base : >-
{%- if resolvconf|bool -%}/etc/resolvconf/resolv.conf.d/base{%- endif -%}
head : >-
{%- if resolvconf|bool -%}/etc/resolvconf/resolv.conf.d/head{%- endif -%}
2017-01-05 23:32:08 +08:00
when : not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
2016-11-30 21:06:11 +08:00
2017-01-05 18:35:16 +08:00
- name : target temporary resolvconf cloud init file (Container Linux by CoreOS)
2017-02-18 05:22:34 +08:00
set_fact :
resolvconffile : /tmp/resolveconf_cloud_init_conf
2017-01-05 23:32:08 +08:00
when : ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
2016-11-30 21:06:11 +08:00
2016-12-21 19:54:25 +08:00
- name : check if /etc/dhclient.conf exists
2017-02-18 05:22:34 +08:00
stat :
path : /etc/dhclient.conf
2016-12-21 19:54:25 +08:00
register : dhclient_stat
- name : target dhclient conf file for /etc/dhclient.conf
2016-11-30 21:06:11 +08:00
set_fact :
2016-12-16 21:49:26 +08:00
dhclientconffile : /etc/dhclient.conf
2016-12-21 19:54:25 +08:00
when : dhclient_stat.stat.exists
2017-01-14 00:14:57 +08:00
- name : check if /etc/dhcp/dhclient.conf exists
2017-02-18 05:22:34 +08:00
stat :
path : /etc/dhcp/dhclient.conf
2017-01-14 00:14:57 +08:00
register : dhcp_dhclient_stat
2016-12-21 19:54:25 +08:00
- name : target dhclient conf file for /etc/dhcp/dhclient.conf
set_fact :
dhclientconffile : /etc/dhcp/dhclient.conf
2017-01-14 00:14:57 +08:00
when : dhcp_dhclient_stat.stat.exists
2016-12-21 19:54:25 +08:00
- name : target dhclient hook file for Red Hat family
set_fact :
2016-11-30 21:06:11 +08:00
dhclienthookfile : /etc/dhcp/dhclient.d/zdnsupdate.sh
when : ansible_os_family == "RedHat"
2016-12-21 19:54:25 +08:00
- name : target dhclient hook file for Debian family
2016-11-30 21:06:11 +08:00
set_fact :
dhclienthookfile : /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
when : ansible_os_family == "Debian"
- name : generate search domains to resolvconf
set_fact :
searchentries :
search {{ ([ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([])) | join(' ') }}
domainentry :
domain {{ dns_domain }}
supersede_search :
supersede domain-search "{{ ([ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([])) | join('", "') }}";
supersede_domain :
supersede domain-name "{{ dns_domain }}";
- name : pick dnsmasq cluster IP or default resolver
set_fact :
dnsmasq_server : |-
2018-03-13 19:00:05 +08:00
{%- if dns_mode in ['kubedns', 'coredns'] and not dns_early|bool -%}
2016-11-30 21:06:11 +08:00
{{ [ skydns_server ] + upstream_dns_servers|default([]) }}
2018-03-13 19:00:05 +08:00
{%- elif dns_mode == 'coredns_dual' and not dns_early|bool -%}
{{ [ skydns_server ] + [ skydns_server_secondary ] + upstream_dns_servers|default([]) }}
2018-01-23 21:28:42 +08:00
{%- elif dns_mode == 'manual' and not dns_early|bool -%}
2018-08-23 22:17:18 +08:00
{{ ( manual_dns_server.split(',') | list) + upstream_dns_servers|default([]) }}
2016-11-30 21:06:11 +08:00
{%- elif dns_early|bool -%}
2016-12-16 18:29:08 +08:00
{{ upstream_dns_servers|default([]) }}
2016-11-30 21:06:11 +08:00
{%- else -%}
2017-10-12 03:40:21 +08:00
{{ [ dnsmasq_dns_server ] }}
2016-11-30 21:06:11 +08:00
{%- endif -%}
- name : generate nameservers to resolvconf
set_fact :
nameserverentries :
2018-01-31 05:26:07 +08:00
nameserver {{( dnsmasq_server + nameservers|d([]) + cloud_resolver|d([])) | join(',nameserver ')}}
2016-12-13 22:43:05 +08:00
supersede_nameserver :
2018-01-31 05:26:07 +08:00
supersede domain-name-servers {{( dnsmasq_server + nameservers|d([]) + cloud_resolver|d([])) | join(', ') }};
2018-08-23 22:51:52 +08:00
- name : gather os specific variables
include_vars : "{{ item }}"
with_first_found :
- files :
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
- "{{ ansible_distribution|lower }}.yml"
- "{{ ansible_os_family|lower }}.yml"
- defaults.yml
paths :
- ../vars
skip : true
2018-10-16 22:15:05 +08:00
- name : force kube_proxy removal if proxy services are replaced by other means
set_fact :
kube_proxy_remove : "{{ (kube_network_plugin == 'kube-router') and (kube_router_run_service_proxy is defined and kube_router_run_service_proxy)| bool }}"
tags :
- facts
- kube-proxy
- name : override kube_proxy_mode to ipvs if kube_proxy_remove is set, as ipvs won't require kube-proxy cleanup when kube-proxy daemonset gets deleted
set_fact :
kube_proxy_mode : 'ipvs'
when :
- kube_proxy_remove
tags :
- facts
- kube-proxy