---
- name: disable SELinux on reboot
selinux:
state: disabled
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Remove podman runc
yum:
name:
- runc
- podman
state: absent
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Update repository cache
dnf:
name: "*"
state: latest
nobest: false
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Install firewalld package
yum:
name: firewalld
state: present
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Disable firewall service for labs
service:
name: firewalld
state: stopped
enabled: false
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Enable kernel module
copy:
src: files/module-k8s.conf
dest: /etc/modules-load.d/k8s.conf
- name: Letting iptables see bridged traffic
copy:
src: files/network-k8s.conf
dest: /etc/sysctl.d/k8s.conf
- name: Reload sysctl config for iptables
command: sysctl --system
- name: Disable SWAP
shell: |
swapoff -a
- name: Disable SWAP in fstab
lineinfile:
path: /etc/fstab
regexp: "swap"
state: absent
- name: Install dnf-utils
yum:
name:
- yum-utils
- iproute-tc
state: present
update_cache: true
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Add Docker repository
shell: dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Install containerd
yum:
name: containerd.io
state: present
update_cache: true
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Backup containerd config.toml
command: mv /etc/containerd/config.toml /etc/containerd/config.toml.orig
- name: Generate default containerd config.toml
shell: containerd config default > /etc/containerd/config.toml
- name: Modify containerd config.toml
replace:
path: /etc/containerd/config.toml
regexp: '^(\s*SystemdCgroup =) false'
replace: '\1 true'
backup: yes
- name: Add kubernetes repository source
copy:
src: files/repo-k8s.repo
dest: /etc/yum.repos.d/kubernetes.repo
- name: start containerd
service:
name: containerd
state: restarted
enabled: true
daemon-reload: yes
- name: Install kubelet, kubeadm
dnf:
name:
- kubelet
- kubeadm
disable_excludes: kubernetes
state: latest
update_cache: true
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Start Kubelet
service:
name: kubelet
enabled: yes
state: started
- name: reboot ALL machines
reboot: