mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-05-15 13:27:43 -02:30
Replace injected Ansible fact variables with ansible_facts in preinstall role (#13232)
This commit is contained in:
@@ -104,7 +104,7 @@ redhat_os_family_extensions:
|
|||||||
- "UniontechOS"
|
- "UniontechOS"
|
||||||
|
|
||||||
# Sets DNSStubListener=no, useful if you get "0.0.0.0:53: bind: address already in use"
|
# Sets DNSStubListener=no, useful if you get "0.0.0.0:53: bind: address already in use"
|
||||||
systemd_resolved_disable_stub_listener: "{{ ansible_os_family in ['Flatcar', 'Flatcar Container Linux by Kinvolk'] }}"
|
systemd_resolved_disable_stub_listener: "{{ ansible_facts['os_family'] in ['Flatcar', 'Flatcar Container Linux by Kinvolk'] }}"
|
||||||
|
|
||||||
# Used to disable File Access Policy Daemon service.
|
# Used to disable File Access Policy Daemon service.
|
||||||
# If service is enabled, the CNI plugin installation will fail
|
# If service is enabled, the CNI plugin installation will fail
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Preinstall | apply resolvconf cloud-init
|
- name: Preinstall | apply resolvconf cloud-init
|
||||||
command: /usr/bin/coreos-cloudinit --from-file {{ resolveconf_cloud_init_conf }}
|
command: /usr/bin/coreos-cloudinit --from-file {{ resolveconf_cloud_init_conf }}
|
||||||
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
when: ansible_facts['os_family'] in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
||||||
listen: Preinstall | propagate resolvconf to k8s components
|
listen: Preinstall | propagate resolvconf to k8s components
|
||||||
|
|
||||||
- name: Preinstall | reload NetworkManager
|
- name: Preinstall | reload NetworkManager
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
---
|
---
|
||||||
- name: Set os_family fact for other redhat-based operating systems
|
- name: Normalize ansible_facts for redhat-family extensions
|
||||||
set_fact:
|
set_fact:
|
||||||
ansible_os_family: "RedHat"
|
ansible_facts: >-
|
||||||
ansible_distribution_major_version: "8"
|
{{ ansible_facts | combine({
|
||||||
when: ansible_distribution in redhat_os_family_extensions
|
'os_family': 'RedHat',
|
||||||
|
'distribution_major_version': '8'
|
||||||
|
}) }}
|
||||||
|
when: ansible_facts['distribution'] in redhat_os_family_extensions
|
||||||
tags:
|
tags:
|
||||||
- facts
|
- facts
|
||||||
|
|
||||||
@@ -86,12 +89,12 @@
|
|||||||
{%- if resolvconf | bool -%}/etc/resolvconf/resolv.conf.d/base{%- endif -%}
|
{%- if resolvconf | bool -%}/etc/resolvconf/resolv.conf.d/base{%- endif -%}
|
||||||
head: >-
|
head: >-
|
||||||
{%- if resolvconf | bool -%}/etc/resolvconf/resolv.conf.d/head{%- endif -%}
|
{%- if resolvconf | bool -%}/etc/resolvconf/resolv.conf.d/head{%- endif -%}
|
||||||
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"] and not is_fedora_coreos
|
when: ansible_facts['os_family'] not in ["Flatcar", "Flatcar Container Linux by Kinvolk"] and not is_fedora_coreos
|
||||||
|
|
||||||
- name: Target temporary resolvconf cloud init file (Flatcar Container Linux by Kinvolk / Fedora CoreOS)
|
- name: Target temporary resolvconf cloud init file (Flatcar Container Linux by Kinvolk / Fedora CoreOS)
|
||||||
set_fact:
|
set_fact:
|
||||||
resolvconffile: /tmp/resolveconf_cloud_init_conf
|
resolvconffile: /tmp/resolveconf_cloud_init_conf
|
||||||
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos
|
when: ansible_facts['os_family'] in ["Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos
|
||||||
|
|
||||||
- name: Check if /etc/dhclient.conf exists
|
- name: Check if /etc/dhclient.conf exists
|
||||||
stat:
|
stat:
|
||||||
@@ -122,12 +125,12 @@
|
|||||||
- name: Target dhclient hook file for Red Hat family
|
- name: Target dhclient hook file for Red Hat family
|
||||||
set_fact:
|
set_fact:
|
||||||
dhclienthookfile: /etc/dhcp/dhclient.d/zdnsupdate.sh
|
dhclienthookfile: /etc/dhcp/dhclient.d/zdnsupdate.sh
|
||||||
when: ansible_os_family == "RedHat"
|
when: ansible_facts['os_family'] == "RedHat"
|
||||||
|
|
||||||
- name: Target dhclient hook file for Debian family
|
- name: Target dhclient hook file for Debian family
|
||||||
set_fact:
|
set_fact:
|
||||||
dhclienthookfile: /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
|
dhclienthookfile: /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_facts['os_family'] == "Debian"
|
||||||
|
|
||||||
- name: Set etcd vars if using kubeadm mode
|
- name: Set etcd vars if using kubeadm mode
|
||||||
set_fact:
|
set_fact:
|
||||||
|
|||||||
@@ -15,25 +15,25 @@
|
|||||||
- not ignore_assert_errors
|
- not ignore_assert_errors
|
||||||
- name: Stop if non systemd OS type
|
- name: Stop if non systemd OS type
|
||||||
assert:
|
assert:
|
||||||
that: ansible_service_mgr == "systemd"
|
that: ansible_facts['service_mgr'] == "systemd"
|
||||||
when: not ignore_assert_errors
|
when: not ignore_assert_errors
|
||||||
|
|
||||||
- name: Stop if the os does not support
|
- name: Stop if the os does not support
|
||||||
assert:
|
assert:
|
||||||
that: (allow_unsupported_distribution_setup | default(false)) or ansible_distribution in supported_os_distributions
|
that: (allow_unsupported_distribution_setup | default(false)) or ansible_facts['distribution'] in supported_os_distributions
|
||||||
msg: "{{ ansible_distribution }} is not a known OS"
|
msg: "{{ ansible_facts['distribution'] }} is not a known OS"
|
||||||
when: not ignore_assert_errors
|
when: not ignore_assert_errors
|
||||||
|
|
||||||
- name: Stop if memory is too small for control plane nodes
|
- name: Stop if memory is too small for control plane nodes
|
||||||
assert:
|
assert:
|
||||||
that: ansible_memtotal_mb >= minimal_master_memory_mb
|
that: ansible_facts['memtotal_mb'] >= minimal_master_memory_mb
|
||||||
when:
|
when:
|
||||||
- not ignore_assert_errors
|
- not ignore_assert_errors
|
||||||
- ('kube_control_plane' in group_names)
|
- ('kube_control_plane' in group_names)
|
||||||
|
|
||||||
- name: Stop if memory is too small for nodes
|
- name: Stop if memory is too small for nodes
|
||||||
assert:
|
assert:
|
||||||
that: ansible_memtotal_mb >= minimal_node_memory_mb
|
that: ansible_facts['memtotal_mb'] >= minimal_node_memory_mb
|
||||||
when:
|
when:
|
||||||
- not ignore_assert_errors
|
- not ignore_assert_errors
|
||||||
- ('kube_node' in group_names)
|
- ('kube_node' in group_names)
|
||||||
@@ -47,8 +47,8 @@
|
|||||||
|
|
||||||
- name: Stop if ip var does not match local ips
|
- name: Stop if ip var does not match local ips
|
||||||
assert:
|
assert:
|
||||||
that: (ip in ansible_all_ipv4_addresses) or (ip in ansible_all_ipv6_addresses)
|
that: (ip in ansible_facts['all_ipv4_addresses']) or (ip in ansible_facts['all_ipv6_addresses'])
|
||||||
msg: "IPv4: '{{ ansible_all_ipv4_addresses }}' and IPv6: '{{ ansible_all_ipv6_addresses }}' do not contain '{{ ip }}'"
|
msg: "IPv4: '{{ ansible_facts['all_ipv4_addresses'] }}' and IPv6: '{{ ansible_facts['all_ipv6_addresses'] }}' do not contain '{{ ip }}'"
|
||||||
when:
|
when:
|
||||||
- not ignore_assert_errors
|
- not ignore_assert_errors
|
||||||
- ip is defined
|
- ip is defined
|
||||||
@@ -63,14 +63,14 @@
|
|||||||
|
|
||||||
- name: Stop if kernel version is too low for cilium
|
- name: Stop if kernel version is too low for cilium
|
||||||
assert:
|
assert:
|
||||||
that: ansible_kernel.split('-')[0] is version('4.9.17', '>=')
|
that: ansible_facts['kernel'].split('-')[0] is version('4.9.17', '>=')
|
||||||
when:
|
when:
|
||||||
- kube_network_plugin == 'cilium' or cilium_deploy_additionally
|
- kube_network_plugin == 'cilium' or cilium_deploy_additionally
|
||||||
- not ignore_assert_errors
|
- not ignore_assert_errors
|
||||||
|
|
||||||
- name: Stop if kernel version is too low for nftables
|
- name: Stop if kernel version is too low for nftables
|
||||||
assert:
|
assert:
|
||||||
that: ansible_kernel.split('-')[0] is version('5.13', '>=')
|
that: ansible_facts['kernel'].split('-')[0] is version('5.13', '>=')
|
||||||
when:
|
when:
|
||||||
- kube_proxy_mode == 'nftables'
|
- kube_proxy_mode == 'nftables'
|
||||||
- not kube_proxy_remove
|
- not kube_proxy_remove
|
||||||
@@ -93,6 +93,6 @@
|
|||||||
|
|
||||||
- name: Stop if download_localhost is enabled for Flatcar Container Linux
|
- name: Stop if download_localhost is enabled for Flatcar Container Linux
|
||||||
assert:
|
assert:
|
||||||
that: ansible_os_family not in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
that: ansible_facts['os_family'] not in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
||||||
msg: "download_run_once not supported for Flatcar Container Linux"
|
msg: "download_run_once not supported for Flatcar Container Linux"
|
||||||
when: download_run_once or download_force_cache
|
when: download_run_once or download_force_cache
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Create temporary resolveconf cloud init file
|
- name: Create temporary resolveconf cloud init file
|
||||||
command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
|
command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
|
||||||
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
when: ansible_facts['os_family'] in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
||||||
|
|
||||||
- name: Add domain/search/nameservers/options to resolv.conf
|
- name: Add domain/search/nameservers/options to resolv.conf
|
||||||
blockinfile:
|
blockinfile:
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
- name: Get temporary resolveconf cloud init file content
|
- name: Get temporary resolveconf cloud init file content
|
||||||
command: cat {{ resolvconffile }}
|
command: cat {{ resolvconffile }}
|
||||||
register: cloud_config
|
register: cloud_config
|
||||||
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
when: ansible_facts['os_family'] in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
||||||
|
|
||||||
- name: Persist resolvconf cloud init file
|
- name: Persist resolvconf cloud init file
|
||||||
template:
|
template:
|
||||||
@@ -54,4 +54,4 @@
|
|||||||
owner: root
|
owner: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
notify: Preinstall | propagate resolvconf to k8s components
|
notify: Preinstall | propagate resolvconf to k8s components
|
||||||
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
when: ansible_facts['os_family'] in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
get_checksum: false
|
get_checksum: false
|
||||||
get_mime: false
|
get_mime: false
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == "RedHat"
|
- ansible_facts['os_family'] == "RedHat"
|
||||||
- "'Amazon' not in ansible_distribution"
|
- "'Amazon' not in ansible_facts['distribution']"
|
||||||
register: slc
|
register: slc
|
||||||
|
|
||||||
- name: Set selinux policy
|
- name: Set selinux policy
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
policy: targeted
|
policy: targeted
|
||||||
state: "{{ preinstall_selinux_state }}"
|
state: "{{ preinstall_selinux_state }}"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family == "RedHat"
|
- ansible_facts['os_family'] == "RedHat"
|
||||||
- "'Amazon' not in ansible_distribution"
|
- "'Amazon' not in ansible_facts['distribution']"
|
||||||
- slc.stat.exists
|
- slc.stat.exists
|
||||||
tags:
|
tags:
|
||||||
- bootstrap_os
|
- bootstrap_os
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
mode: "0644"
|
mode: "0644"
|
||||||
when:
|
when:
|
||||||
- disable_ipv6_dns
|
- disable_ipv6_dns
|
||||||
- not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
- ansible_facts['os_family'] not in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
||||||
tags:
|
tags:
|
||||||
- bootstrap_os
|
- bootstrap_os
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
/etc/ntp.conf
|
/etc/ntp.conf
|
||||||
{%- elif ntp_package == "ntpsec" -%}
|
{%- elif ntp_package == "ntpsec" -%}
|
||||||
/etc/ntpsec/ntp.conf
|
/etc/ntpsec/ntp.conf
|
||||||
{%- elif ansible_os_family in ['RedHat', 'Suse'] -%}
|
{%- elif ansible_facts['os_family'] in ['RedHat', 'Suse'] -%}
|
||||||
/etc/chrony.conf
|
/etc/chrony.conf
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
/etc/chrony/chrony.conf
|
/etc/chrony/chrony.conf
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
ntp_service_name: >-
|
ntp_service_name: >-
|
||||||
{% if ntp_package == "chrony" -%}
|
{% if ntp_package == "chrony" -%}
|
||||||
chronyd
|
chronyd
|
||||||
{%- elif ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk", "RedHat", "Suse"] -%}
|
{%- elif ansible_facts['os_family'] in ["Flatcar", "Flatcar Container Linux by Kinvolk", "RedHat", "Suse"] -%}
|
||||||
ntpd
|
ntpd
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
ntp
|
ntp
|
||||||
@@ -72,14 +72,14 @@
|
|||||||
when:
|
when:
|
||||||
- ntp_timezone
|
- ntp_timezone
|
||||||
- not is_fedora_coreos
|
- not is_fedora_coreos
|
||||||
- not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
- ansible_facts['os_family'] not in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
||||||
|
|
||||||
- name: Gather selinux facts
|
- name: Gather selinux facts
|
||||||
ansible.builtin.setup:
|
ansible.builtin.setup:
|
||||||
gather_subset: selinux
|
gather_subset: selinux
|
||||||
when:
|
when:
|
||||||
- ntp_timezone
|
- ntp_timezone
|
||||||
- ansible_os_family == "RedHat"
|
- ansible_facts['os_family'] == "RedHat"
|
||||||
|
|
||||||
- name: Put SELinux in permissive mode, logging actions that would be blocked.
|
- name: Put SELinux in permissive mode, logging actions that would be blocked.
|
||||||
ansible.posix.selinux:
|
ansible.posix.selinux:
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
state: permissive
|
state: permissive
|
||||||
when:
|
when:
|
||||||
- ntp_timezone
|
- ntp_timezone
|
||||||
- ansible_os_family == "RedHat"
|
- ansible_facts['os_family'] == "RedHat"
|
||||||
- ansible_facts.selinux.status == 'enabled'
|
- ansible_facts.selinux.status == 'enabled'
|
||||||
- ansible_facts.selinux.mode == 'enforcing'
|
- ansible_facts.selinux.mode == 'enforcing'
|
||||||
|
|
||||||
@@ -103,5 +103,5 @@
|
|||||||
state: "{{ preinstall_selinux_state }}"
|
state: "{{ preinstall_selinux_state }}"
|
||||||
when:
|
when:
|
||||||
- ntp_timezone
|
- ntp_timezone
|
||||||
- ansible_os_family == "RedHat"
|
- ansible_facts['os_family'] == "RedHat"
|
||||||
- ansible_facts.selinux.status == 'enabled'
|
- ansible_facts.selinux.status == 'enabled'
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
notify: Preinstall | propagate resolvconf to k8s components
|
notify: Preinstall | propagate resolvconf to k8s components
|
||||||
when: ansible_os_family not in [ "RedHat", "Suse" ]
|
when: ansible_facts['os_family'] not in [ "RedHat", "Suse" ]
|
||||||
|
|
||||||
- name: Configure dhclient hooks for resolv.conf (RH-only)
|
- name: Configure dhclient hooks for resolv.conf (RH-only)
|
||||||
template:
|
template:
|
||||||
@@ -35,4 +35,4 @@
|
|||||||
owner: root
|
owner: root
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
notify: Preinstall | propagate resolvconf to k8s components
|
notify: Preinstall | propagate resolvconf to k8s components
|
||||||
when: ansible_os_family == "RedHat"
|
when: ansible_facts['os_family'] == "RedHat"
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
- dns_mode != 'none'
|
- dns_mode != 'none'
|
||||||
- resolvconf_mode == 'host_resolvconf'
|
- resolvconf_mode == 'host_resolvconf'
|
||||||
- dhclientconffile is defined
|
- dhclientconffile is defined
|
||||||
- not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
- ansible_facts['os_family'] not in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
||||||
tags:
|
tags:
|
||||||
- bootstrap_os
|
- bootstrap_os
|
||||||
- resolvconf
|
- resolvconf
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
- dns_mode != 'none'
|
- dns_mode != 'none'
|
||||||
- resolvconf_mode != 'host_resolvconf'
|
- resolvconf_mode != 'host_resolvconf'
|
||||||
- dhclientconffile is defined
|
- dhclientconffile is defined
|
||||||
- not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
- ansible_facts['os_family'] not in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
||||||
tags:
|
tags:
|
||||||
- bootstrap_os
|
- bootstrap_os
|
||||||
- resolvconf
|
- resolvconf
|
||||||
|
|||||||
Reference in New Issue
Block a user