2016-11-30 14:06:11 +01:00
---
2020-02-18 09:15:29 +01:00
- name : Force binaries directory for Container Linux by CoreOS and Flatcar
2018-08-23 16:51:52 +02:00
set_fact :
bin_dir : "/opt/bin"
2020-02-18 09:15:29 +01:00
when : ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"]
2018-08-23 16:51:52 +02:00
tags :
- facts
2020-03-17 22:31:27 +01:00
- name : check if booted with ostree
2018-08-23 16:51:52 +02:00
stat :
path : /run/ostree-booted
register : ostree
2020-03-17 11:12:21 +01:00
- name : set is_fedora_coreos
lineinfile :
path : /etc/os-release
line : "VARIANT_ID=coreos"
state : present
check_mode : yes
register : os_variant_coreos
2020-06-16 09:24:03 +02:00
changed_when : false
2020-03-17 11:12:21 +01:00
- name : set is_fedora_coreos
set_fact :
is_fedora_coreos : "{{ ostree.stat.exists and os_variant_coreos is not changed }}"
2016-11-30 14:06:11 +01:00
- name : check resolvconf
shell : which resolvconf
register : resolvconf
2016-12-27 12:38:54 +01:00
failed_when : false
2016-11-30 14:06:11 +01:00
changed_when : false
2017-02-06 21:13:21 +03:00
check_mode : no
2016-11-30 14:06:11 +01:00
2019-11-06 14:33:52 +03:00
- name : check systemd-resolved
command : systemctl is-active systemd-resolved
register : systemd_resolved_enabled
failed_when : false
changed_when : false
check_mode : no
2019-05-16 09:27:43 +02:00
- name : set dns facts
set_fact :
2016-11-30 14:06:11 +01:00
resolvconf : >-
{%- if resolvconf.rc == 0 -%}true{%- else -%}false{%- endif -%}
2016-11-30 14:06:11 +01:00
bogus_domains : |-
2016-11-30 14:06:11 +01:00
{% for d in [ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([]) -%}
2019-05-02 23:24:21 +02:00
{{ dns_domain }}.{{ d }}./{{ d }}.{{ d }}./com.{{ d }}./
2016-11-30 14:06:11 +01:00
{%- endfor %}
2018-01-31 00:26:07 +03:00
cloud_resolver : >-
2017-04-20 09:53:01 -04:00
{%- if cloud_provider is defined and cloud_provider == 'gce' -%}
2018-01-31 00:26:07 +03:00
[ '169.254.169.254' ]
2017-04-20 09:53:01 -04:00
{%- elif cloud_provider is defined and cloud_provider == 'aws' -%}
2018-01-31 00:26:07 +03:00
[ '169.254.169.253' ]
2017-04-20 09:53:01 -04:00
{%- else -%}
2018-01-31 00:26:07 +03:00
[ ]
2017-04-20 09:53:01 -04:00
{%- endif -%}
2016-11-30 14:06:11 +01:00
2017-01-18 19:18:47 +03:00
- name : check if kubelet is configured
2016-11-30 14:06:11 +01:00
stat :
2017-01-18 19:18:47 +03:00
path : "{{ kube_config_dir }}/kubelet.env"
register : kubelet_configured
2016-11-30 14:06:11 +01:00
changed_when : false
- name : check if early DNS configuration stage
set_fact :
dns_early : >-
2017-01-18 19:18:47 +03:00
{%- if kubelet_configured.stat.exists -%}false{%- else -%}true{%- endif -%}
2016-11-30 14:06:11 +01: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 -%}
2020-05-18 11:27:36 +02:00
when : not ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] and not is_fedora_coreos
2016-11-30 14:06:11 +01:00
2017-01-05 11:35:16 +01:00
- name : target temporary resolvconf cloud init file (Container Linux by CoreOS)
2017-02-17 16:22:34 -05:00
set_fact :
resolvconffile : /tmp/resolveconf_cloud_init_conf
2020-05-18 11:27:36 +02:00
when : ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos
2016-11-30 14:06:11 +01:00
2016-12-21 12:54:25 +01:00
- name : check if /etc/dhclient.conf exists
2017-02-17 16:22:34 -05:00
stat :
path : /etc/dhclient.conf
2016-12-21 12:54:25 +01:00
register : dhclient_stat
- name : target dhclient conf file for /etc/dhclient.conf
2016-11-30 14:06:11 +01:00
set_fact :
2016-12-16 14:49:26 +01:00
dhclientconffile : /etc/dhclient.conf
2016-12-21 12:54:25 +01:00
when : dhclient_stat.stat.exists
2017-01-13 10:14:57 -06:00
- name : check if /etc/dhcp/dhclient.conf exists
2017-02-17 16:22:34 -05:00
stat :
path : /etc/dhcp/dhclient.conf
2017-01-13 10:14:57 -06:00
register : dhcp_dhclient_stat
2016-12-21 12:54:25 +01:00
- name : target dhclient conf file for /etc/dhcp/dhclient.conf
set_fact :
dhclientconffile : /etc/dhcp/dhclient.conf
2017-01-13 10:14:57 -06:00
when : dhcp_dhclient_stat.stat.exists
2016-12-21 12:54:25 +01:00
- name : target dhclient hook file for Red Hat family
set_fact :
2016-11-30 14:06:11 +01:00
dhclienthookfile : /etc/dhcp/dhclient.d/zdnsupdate.sh
when : ansible_os_family == "RedHat"
2016-12-21 12:54:25 +01:00
- name : target dhclient hook file for Debian family
2016-11-30 14:06:11 +01: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 }}";
2019-04-01 22:32:34 +03:00
- name : pick coredns cluster IP or default resolver
2016-11-30 14:06:11 +01:00
set_fact :
2019-04-01 22:32:34 +03:00
coredns_server : |-
{%- if dns_mode == 'coredns' and not dns_early|bool -%}
2019-12-02 19:41:05 +03:00
{{ [ skydns_server ] }}
2018-03-13 12:00:05 +01:00
{%- elif dns_mode == 'coredns_dual' and not dns_early|bool -%}
2019-12-02 19:41:05 +03:00
{{ [ skydns_server ] + [ skydns_server_secondary ] }}
2018-01-23 16:28:42 +03:00
{%- elif dns_mode == 'manual' and not dns_early|bool -%}
2019-12-02 19:41:05 +03:00
{{ ( manual_dns_server.split(',') | list) }}
2016-11-30 14:06:11 +01:00
{%- elif dns_early|bool -%}
2016-12-16 11:29:08 +01:00
{{ upstream_dns_servers|default([]) }}
2016-11-30 14:06:11 +01:00
{%- endif -%}
- name : generate nameservers to resolvconf
set_fact :
nameserverentries :
2019-06-04 10:13:02 +03:00
nameserver {{ ( coredns_server + nameservers|d([]) + cloud_resolver|d([])) | unique | join(',nameserver ') }}
2016-12-13 15:43:05 +01:00
supersede_nameserver :
2019-06-04 10:13:02 +03:00
supersede domain-name-servers {{ ( coredns_server + nameservers|d([]) + cloud_resolver|d([])) | unique | join(', ') }};
2018-08-23 16:51:52 +02: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 11:15:05 -03:00
- 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
2019-06-20 11:12:51 -07:00
- name : set etcd vars if using kubeadm mode
set_fact :
etcd_cert_dir : "{{ kube_cert_dir }}"
kube_etcd_cacert_file : "etcd/ca.crt"
kube_etcd_cert_file : "apiserver-etcd-client.crt"
kube_etcd_key_file : "apiserver-etcd-client.key"
when :
- etcd_kubeadm_enabled
2019-07-30 15:00:10 -04:00
- name : check /usr readonly
stat :
path : "/usr"
register : usr
- name : set alternate flexvolume path
set_fact :
kubelet_flexvolumes_plugins_dir : /var/lib/kubelet/volumeplugins
when : not usr.stat.writeable