Do not use ‘yes/no’ for boolean values (#11472)

Consistent boolean values in ansible playbooks
This commit is contained in:
Vlad Korolev
2024-08-28 01:30:56 -04:00
committed by GitHub
parent 5c5421e453
commit 9a7b021eb8
162 changed files with 507 additions and 508 deletions

View File

@@ -31,9 +31,9 @@
- name: Preinstall | kube-apiserver configured
stat:
path: "{{ kube_manifest_dir }}/kube-apiserver.yaml"
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: kube_apiserver_set
when: inventory_hostname in groups['kube_control_plane'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'
listen: Preinstall | propagate resolvconf to k8s components
@@ -42,9 +42,9 @@
- name: Preinstall | kube-controller configured
stat:
path: "{{ kube_manifest_dir }}/kube-controller-manager.yaml"
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: kube_controller_set
when: inventory_hostname in groups['kube_control_plane'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'
listen: Preinstall | propagate resolvconf to k8s components
@@ -109,7 +109,7 @@
- name: Preinstall | wait for the apiserver to be running
uri:
url: "{{ kube_apiserver_endpoint }}/healthz"
validate_certs: no
validate_certs: false
register: result
until: result.status == 200
retries: 60

View File

@@ -2,9 +2,9 @@
- name: Check if /etc/fstab exists
stat:
path: "/etc/fstab"
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: fstab_file
- name: Remove swapfile from /etc/fstab

View File

@@ -12,24 +12,24 @@
register: resolvconf
failed_when: false
changed_when: false
check_mode: no
check_mode: false
- name: Check existence of /etc/resolvconf/resolv.conf.d
stat:
path: /etc/resolvconf/resolv.conf.d
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
failed_when: false
register: resolvconfd_path
- name: Check status of /etc/resolv.conf
stat:
path: /etc/resolv.conf
follow: no
get_attributes: no
get_checksum: no
get_mime: no
follow: false
get_attributes: false
get_checksum: false
get_mime: false
failed_when: false
register: resolvconf_stat
@@ -72,7 +72,7 @@
register: systemd_resolved_enabled
failed_when: false
changed_when: false
check_mode: no
check_mode: false
- name: Set default dns if remove_default_searchdomains is false
set_fact:
@@ -94,9 +94,9 @@
- name: Check if kubelet is configured
stat:
path: "{{ kube_config_dir }}/kubelet.env"
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: kubelet_configured
changed_when: false
@@ -121,9 +121,9 @@
- name: Check if /etc/dhclient.conf exists
stat:
path: /etc/dhclient.conf
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: dhclient_stat
- name: Target dhclient conf file for /etc/dhclient.conf
@@ -134,9 +134,9 @@
- name: Check if /etc/dhcp/dhclient.conf exists
stat:
path: /etc/dhcp/dhclient.conf
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: dhcp_dhclient_stat
- name: Target dhclient conf file for /etc/dhcp/dhclient.conf
@@ -218,9 +218,9 @@
- name: Check /usr readonly
stat:
path: "/usr"
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: usr
- name: Set alternate flexvolume path

View File

@@ -44,7 +44,7 @@
assert:
that: item.value | type_debug == 'bool'
msg: "{{ item.value }} isn't a bool"
run_once: yes
run_once: true
with_items:
- { name: download_run_once, value: "{{ download_run_once }}" }
- { name: deploy_netchecker, value: "{{ deploy_netchecker }}" }
@@ -172,21 +172,21 @@
that:
- kube_service_addresses | ansible.utils.ipaddr('net')
msg: "kube_service_addresses = '{{ kube_service_addresses }}' is not a valid network range"
run_once: yes
run_once: true
- name: "Check that kube_pods_subnet is a network range"
assert:
that:
- kube_pods_subnet | ansible.utils.ipaddr('net')
msg: "kube_pods_subnet = '{{ kube_pods_subnet }}' is not a valid network range"
run_once: yes
run_once: true
- name: "Check that kube_pods_subnet does not collide with kube_service_addresses"
assert:
that:
- kube_pods_subnet | ansible.utils.ipaddr(kube_service_addresses) | string == 'None'
msg: "kube_pods_subnet cannot be the same network segment as kube_service_addresses"
run_once: yes
run_once: true
- name: "Check that IP range is enough for the nodes"
assert:
@@ -194,7 +194,7 @@
- 2 ** (kube_network_node_prefix - kube_pods_subnet | ansible.utils.ipaddr('prefix')) >= groups['k8s_cluster'] | length
msg: "Not enough IPs are available for the desired node count."
when: kube_network_plugin != 'calico'
run_once: yes
run_once: true
- name: Stop if unknown dns mode
assert:
@@ -246,7 +246,7 @@
# TODO: Clean this task up when we drop backward compatibility support for `etcd_kubeadm_enabled`
- name: Stop if etcd deployment type is not host or kubeadm when container_manager != docker and etcd_kubeadm_enabled is not defined
run_once: yes
run_once: true
when: etcd_kubeadm_enabled is defined
block:
- name: Warn the user if they are still using `etcd_kubeadm_enabled`
@@ -292,7 +292,7 @@
assert:
that: containerd_version is version(containerd_min_version_required, '>=')
msg: "containerd_version is too low. Minimum version {{ containerd_min_version_required }}"
run_once: yes
run_once: true
when:
- containerd_version not in ['latest', 'edge', 'stable']
- container_manager == 'containerd'

View File

@@ -48,9 +48,9 @@
- name: Check if kubernetes kubeadm compat cert dir exists
stat:
path: "{{ kube_cert_compat_dir }}"
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: kube_cert_compat_dir_check
when:
- inventory_hostname in groups['k8s_cluster']

View File

@@ -16,7 +16,7 @@
options ndots:{{ ndots }} timeout:{{ dns_timeout | default('2') }} attempts:{{ dns_attempts | default('2') }}
state: present
insertbefore: BOF
create: yes
create: true
backup: "{{ not resolvconf_stat.stat.islnk }}"
marker: "# Ansible entries {mark}"
mode: "0644"

View File

@@ -3,7 +3,7 @@
file:
path: "/etc/NetworkManager/conf.d"
state: directory
recurse: yes
recurse: true
- name: NetworkManager | Prevent NetworkManager from managing Calico interfaces (cali*/tunl*/vxlan.calico)
copy:

View File

@@ -6,7 +6,7 @@
option: servers
value: "{{ nameserverentries }}"
mode: '0600'
backup: yes
backup: true
when:
- nameserverentries != "127.0.0.53" or systemd_resolved_enabled.rc != 0
notify: Preinstall | update resolvconf for networkmanager
@@ -23,7 +23,7 @@
option: searches
value: "{{ (default_searchdomains | default([]) + searchdomains | default([])) | join(',') }}"
mode: '0600'
backup: yes
backup: true
notify: Preinstall | update resolvconf for networkmanager
- name: NetworkManager | Add DNS options to NM configuration
@@ -33,5 +33,5 @@
option: options
value: "ndots:{{ ndots }},timeout:{{ dns_timeout | default('2') }},attempts:{{ dns_attempts | default('2') }}"
mode: '0600'
backup: yes
backup: true
notify: Preinstall | update resolvconf for networkmanager

View File

@@ -34,7 +34,7 @@
- name: Update package management cache (APT)
apt:
update_cache: yes
update_cache: true
cache_valid_time: 3600
when: ansible_os_family == "Debian"
tags:

View File

@@ -3,9 +3,9 @@
- name: Confirm selinux deployed
stat:
path: /etc/selinux/config
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
when:
- ansible_os_family == "RedHat"
- "'Amazon' not in ansible_distribution"
@@ -27,8 +27,8 @@
dest: /etc/gai.conf
line: "precedence ::ffff:0:0/96 100"
state: present
create: yes
backup: yes
create: true
backup: true
mode: "0644"
when:
- disable_ipv6_dns
@@ -47,9 +47,9 @@
- name: Stat sysctl file configuration
stat:
path: "{{ sysctl_file_path }}"
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: sysctl_file_stat
tags:
- bootstrap-os
@@ -75,7 +75,7 @@
name: net.ipv4.ip_forward
value: "1"
state: present
reload: yes
reload: true
- name: Enable ipv6 forwarding
ansible.posix.sysctl:
@@ -83,15 +83,15 @@
name: net.ipv6.conf.all.forwarding
value: "1"
state: present
reload: yes
reload: true
when: enable_dual_stack_networks | bool
- name: Check if we need to set fs.may_detach_mounts
stat:
path: /proc/sys/fs/may_detach_mounts
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: fs_may_detach_mounts
ignore_errors: true # noqa ignore-errors
@@ -101,7 +101,7 @@
name: fs.may_detach_mounts
value: 1
state: present
reload: yes
reload: true
when: fs_may_detach_mounts.stat.exists | d(false)
- name: Ensure kubelet expected parameters are set
@@ -110,7 +110,7 @@
name: "{{ item.name }}"
value: "{{ item.value }}"
state: present
reload: yes
reload: true
with_items:
- { name: kernel.keys.root_maxbytes, value: 25000000 }
- { name: kernel.keys.root_maxkeys, value: 1000000 }
@@ -133,7 +133,7 @@
name: "{{ item.name }}"
value: "{{ item.value }}"
state: present
reload: yes
reload: true
with_items: "{{ additional_sysctl }}"
- name: Disable fapolicyd service

View File

@@ -11,17 +11,17 @@
{% endfor %}
delegate_to: localhost
connection: local
delegate_facts: yes
run_once: yes
delegate_facts: true
run_once: true
- name: Hosts | populate inventory into hosts file
blockinfile:
path: /etc/hosts
block: "{{ hostvars.localhost.etc_hosts_inventory_block }}"
state: "{{ 'present' if populate_inventory_to_hosts_file else 'absent' }}"
create: yes
backup: yes
unsafe_writes: yes
create: true
backup: true
unsafe_writes: true
marker: "# Ansible inventory hosts {mark}"
mode: "0644"
@@ -31,8 +31,8 @@
regexp: ".*{{ apiserver_loadbalancer_domain_name }}$"
line: "{{ loadbalancer_apiserver.address }} {{ apiserver_loadbalancer_domain_name }}"
state: present
backup: yes
unsafe_writes: yes
backup: true
unsafe_writes: true
when:
- populate_loadbalancer_apiserver_to_hosts_file
- loadbalancer_apiserver is defined
@@ -69,8 +69,8 @@
line: "{{ item.key }} {{ item.value | join(' ') }}"
regexp: "^{{ item.key }}.*$"
state: present
backup: yes
unsafe_writes: yes
backup: true
unsafe_writes: true
loop: "{{ etc_hosts_localhosts_dict_target | default({}) | dict2items }}"
# gather facts to update ansible_fqdn

View File

@@ -6,10 +6,10 @@
{{ item }}
{% endfor %}
path: "{{ dhclientconffile }}"
create: yes
create: true
state: present
insertbefore: BOF
backup: yes
backup: true
marker: "# Ansible entries {mark}"
mode: "0644"
notify: Preinstall | propagate resolvconf to k8s components

View File

@@ -7,7 +7,7 @@
blockinfile:
path: "{{ dhclientconffile }}"
state: absent
backup: yes
backup: true
marker: "# Ansible entries {mark}"
notify: Preinstall | propagate resolvconf to k8s components

View File

@@ -22,7 +22,7 @@
- name: Check if growpart needs to be run
command: growpart -N {{ device }} {{ partition }}
failed_when: False
failed_when: false
changed_when: "'NOCHANGE:' not in growpart_needed.stdout"
register: growpart_needed
environment:
@@ -30,7 +30,7 @@
- name: Check fs type
command: file -Ls {{ root_device }}
changed_when: False
changed_when: false
register: fs_type
- name: Run growpart # noqa no-handler

View File

@@ -121,9 +121,9 @@
- name: Check if we are running inside a Azure VM
stat:
path: /var/lib/waagent/
get_attributes: no
get_checksum: no
get_mime: no
get_attributes: false
get_checksum: false
get_mime: false
register: azure_check
when:
- not dns_late