2018-09-06 22:26:57 +08:00
|
|
|
---
|
2018-08-23 22:51:52 +08:00
|
|
|
# Todo : selinux configuration
|
|
|
|
- name: Confirm selinux deployed
|
|
|
|
stat:
|
|
|
|
path: /etc/selinux/config
|
2021-02-10 21:36:59 +08:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2019-11-11 23:05:41 +08:00
|
|
|
when:
|
|
|
|
- ansible_os_family == "RedHat"
|
|
|
|
- "'Amazon' not in ansible_distribution"
|
2018-08-23 22:51:52 +08:00
|
|
|
register: slc
|
|
|
|
|
|
|
|
- name: Set selinux policy
|
2023-06-26 18:15:45 +08:00
|
|
|
ansible.posix.selinux:
|
2018-08-23 22:51:52 +08:00
|
|
|
policy: targeted
|
|
|
|
state: "{{ preinstall_selinux_state }}"
|
|
|
|
when:
|
|
|
|
- ansible_os_family == "RedHat"
|
2019-11-11 23:05:41 +08:00
|
|
|
- "'Amazon' not in ansible_distribution"
|
2019-04-17 23:42:03 +08:00
|
|
|
- slc.stat.exists
|
2018-08-23 22:51:52 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
|
|
|
|
|
|
|
- name: Disable IPv6 DNS lookup
|
|
|
|
lineinfile:
|
|
|
|
dest: /etc/gai.conf
|
|
|
|
line: "precedence ::ffff:0:0/96 100"
|
|
|
|
state: present
|
2020-06-12 15:55:55 +08:00
|
|
|
create: yes
|
2018-08-23 22:51:52 +08:00
|
|
|
backup: yes
|
2024-07-26 09:42:20 +08:00
|
|
|
mode: "0644"
|
2018-08-23 22:51:52 +08:00
|
|
|
when:
|
|
|
|
- disable_ipv6_dns
|
2021-10-02 00:11:23 +08:00
|
|
|
- not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
2018-08-23 22:51:52 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
|
|
|
|
2022-02-02 00:12:10 +08:00
|
|
|
- name: Clean previously used sysctl file locations
|
|
|
|
file:
|
|
|
|
path: "/etc/sysctl.d/{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- ipv4-ip_forward.conf
|
|
|
|
- bridge-nf-call.conf
|
|
|
|
|
2018-08-23 22:51:52 +08:00
|
|
|
- name: Stat sysctl file configuration
|
|
|
|
stat:
|
2019-05-03 05:24:21 +08:00
|
|
|
path: "{{ sysctl_file_path }}"
|
2021-02-10 21:36:59 +08:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2018-08-23 22:51:52 +08:00
|
|
|
register: sysctl_file_stat
|
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
|
|
|
|
|
|
|
- name: Change sysctl file path to link source if linked
|
|
|
|
set_fact:
|
2019-05-03 05:24:21 +08:00
|
|
|
sysctl_file_path: "{{ sysctl_file_stat.stat.lnk_source }}"
|
2018-08-23 22:51:52 +08:00
|
|
|
when:
|
|
|
|
- sysctl_file_stat.stat.islnk is defined
|
|
|
|
- sysctl_file_stat.stat.islnk
|
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
|
|
|
|
2018-12-18 17:39:25 +08:00
|
|
|
- name: Make sure sysctl file path folder exists
|
|
|
|
file:
|
|
|
|
name: "{{ sysctl_file_path | dirname }}"
|
|
|
|
state: directory
|
2024-07-26 09:42:20 +08:00
|
|
|
mode: "0755"
|
2018-12-18 17:39:25 +08:00
|
|
|
|
2018-08-23 22:51:52 +08:00
|
|
|
- name: Enable ip forwarding
|
2023-06-26 18:15:45 +08:00
|
|
|
ansible.posix.sysctl:
|
2019-05-03 05:24:21 +08:00
|
|
|
sysctl_file: "{{ sysctl_file_path }}"
|
2018-08-23 22:51:52 +08:00
|
|
|
name: net.ipv4.ip_forward
|
2020-11-27 19:54:49 +08:00
|
|
|
value: "1"
|
2018-08-23 22:51:52 +08:00
|
|
|
state: present
|
|
|
|
reload: yes
|
2020-09-03 22:41:41 +08:00
|
|
|
|
2020-10-26 15:10:53 +08:00
|
|
|
- name: Enable ipv6 forwarding
|
2023-06-26 18:15:45 +08:00
|
|
|
ansible.posix.sysctl:
|
2020-10-26 15:10:53 +08:00
|
|
|
sysctl_file: "{{ sysctl_file_path }}"
|
|
|
|
name: net.ipv6.conf.all.forwarding
|
2023-04-19 18:21:12 +08:00
|
|
|
value: "1"
|
2020-10-26 15:10:53 +08:00
|
|
|
state: present
|
|
|
|
reload: yes
|
|
|
|
when: enable_dual_stack_networks | bool
|
|
|
|
|
2022-03-22 08:36:13 +08:00
|
|
|
- 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
|
|
|
|
register: fs_may_detach_mounts
|
|
|
|
ignore_errors: true # noqa ignore-errors
|
|
|
|
|
|
|
|
- name: Set fs.may_detach_mounts if needed
|
2023-06-26 18:15:45 +08:00
|
|
|
ansible.posix.sysctl:
|
2022-03-22 08:36:13 +08:00
|
|
|
sysctl_file: "{{ sysctl_file_path }}"
|
|
|
|
name: fs.may_detach_mounts
|
|
|
|
value: 1
|
|
|
|
state: present
|
|
|
|
reload: yes
|
|
|
|
when: fs_may_detach_mounts.stat.exists | d(false)
|
|
|
|
|
2024-05-14 15:39:11 +08:00
|
|
|
- name: Ensure kubelet expected parameters are set
|
2023-06-26 18:15:45 +08:00
|
|
|
ansible.posix.sysctl:
|
2022-02-02 00:12:10 +08:00
|
|
|
sysctl_file: "{{ sysctl_file_path }}"
|
2020-09-03 22:41:41 +08:00
|
|
|
name: "{{ item.name }}"
|
|
|
|
value: "{{ item.value }}"
|
|
|
|
state: present
|
|
|
|
reload: yes
|
|
|
|
with_items:
|
2022-04-07 23:33:59 +08:00
|
|
|
- { name: kernel.keys.root_maxbytes, value: 25000000 }
|
|
|
|
- { name: kernel.keys.root_maxkeys, value: 1000000 }
|
2020-09-03 22:41:41 +08:00
|
|
|
- { name: kernel.panic, value: 10 }
|
|
|
|
- { name: kernel.panic_on_oops, value: 1 }
|
2022-04-07 23:33:59 +08:00
|
|
|
- { name: vm.overcommit_memory, value: 1 }
|
|
|
|
- { name: vm.panic_on_oom, value: 0 }
|
2023-07-05 11:36:54 +08:00
|
|
|
when: kubelet_protect_kernel_defaults | bool
|
2021-03-10 00:07:00 +08:00
|
|
|
|
|
|
|
- name: Check dummy module
|
2023-06-26 18:15:45 +08:00
|
|
|
community.general.modprobe:
|
2021-03-10 00:07:00 +08:00
|
|
|
name: dummy
|
|
|
|
state: present
|
|
|
|
params: 'numdummies=0'
|
|
|
|
when: enable_nodelocaldns
|
2022-10-03 14:06:14 +08:00
|
|
|
|
|
|
|
- name: Set additional sysctl variables
|
2023-06-26 18:15:45 +08:00
|
|
|
ansible.posix.sysctl:
|
2022-10-03 14:06:14 +08:00
|
|
|
sysctl_file: "{{ sysctl_file_path }}"
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
value: "{{ item.value }}"
|
|
|
|
state: present
|
|
|
|
reload: yes
|
|
|
|
with_items: "{{ additional_sysctl }}"
|
2023-06-24 11:49:06 +08:00
|
|
|
|
|
|
|
- name: Disable fapolicyd service
|
|
|
|
failed_when: false
|
2024-07-26 16:11:39 +08:00
|
|
|
systemd_service:
|
2023-06-24 11:49:06 +08:00
|
|
|
name: fapolicyd
|
|
|
|
state: stopped
|
|
|
|
enabled: false
|
|
|
|
when: disable_fapolicyd
|