# ------------------------------------------------------------------------------ # FILE: roles/common/tasks/main.yml # ------------------------------------------------------------------------------ - name: Disable swap command: swapoff -a changed_when: false - name: Persist swap off by commenting out swap in fstab replace: path: /etc/fstab regexp: '^(\s*)([^#\n]+\s+swap\s+.*)$' replace: '#\2' backup: yes - name: Load required kernel modules modprobe: name: "{{ item }}" state: present loop: - overlay - br_netfilter - name: Persist kernel modules on boot copy: dest: /etc/modules-load.d/k8s.conf content: | overlay br_netfilter - name: Configure required sysctl params for Kubernetes copy: dest: /etc/sysctl.d/k8s.conf content: | net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-ip6tables = 1 net.ipv4.ip_forward = 1 - name: Apply sysctl params without reboot command: sysctl --system changed_when: false - name: Set SELinux to permissive mode selinux: policy: targeted state: permissive - name: Install DNF plugins core for managing repositories dnf: name: dnf-plugins-core state: present - name: Add Docker CE repository command: dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo args: creates: /etc/yum.repos.d/docker-ce.repo - name: Install containerd dnf: name: containerd.io state: present - name: Create containerd config directory file: path: /etc/containerd state: directory - name: Generate default containerd config and enable SystemdCgroup shell: | containerd config default > /etc/containerd/config.toml sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml args: creates: /etc/containerd/config.toml - name: Restart and enable containerd service systemd: name: containerd state: restarted enabled: yes daemon_reload: yes - name: Add Kubernetes repository yum_repository: name: kubernetes description: Kubernetes baseurl: https://pkgs.k8s.io/core:/stable:/v1.33/rpm/ gpgkey: https://pkgs.k8s.io/core:/stable:/v1.33/rpm/repodata/repomd.xml.key gpgcheck: yes - name: Install Kubernetes packages dnf: name: - kubelet - kubeadm - kubectl state: present disable_excludes: kubernetes - name: Enable the kubelet service systemd: name: kubelet enabled: yes