diff --git a/roles/kubernetes/preinstall/tasks/0010-swapoff.yml b/roles/kubernetes/preinstall/tasks/0010-swapoff.yml index c603f37b1..53bcf2d12 100644 --- a/roles/kubernetes/preinstall/tasks/0010-swapoff.yml +++ b/roles/kubernetes/preinstall/tasks/0010-swapoff.yml @@ -1,28 +1,8 @@ --- -- name: Remove swapfile from /etc/fstab - ansible.posix.mount: - name: "{{ item }}" - fstype: swap - state: absent - loop: - - swap - - none - -# kubelet fails even if ansible_swaptotal_mb = 0 -- name: Check swap - command: /sbin/swapon -s - register: swapon - changed_when: no +- name: Mask swap.target (persist swapoff) + ansible.builtin.systemd_service: + name: swap.target + masked: true - name: Disable swap command: /sbin/swapoff -a - when: - - swapon.stdout - ignore_errors: "{{ ansible_check_mode }}" # noqa ignore-errors - -- name: Disable swapOnZram for Fedora - command: touch /etc/systemd/zram-generator.conf - when: - - swapon.stdout - - ansible_distribution in ['Fedora'] - ignore_errors: "{{ ansible_check_mode }}" # noqa ignore-errors