2018-06-21 14:17:03 +08:00
|
|
|
---
|
|
|
|
- name: Remove swapfile from /etc/fstab
|
2023-06-26 18:15:45 +08:00
|
|
|
ansible.posix.mount:
|
2018-12-11 18:42:00 +08:00
|
|
|
name: "{{ item }}"
|
2018-06-21 14:17:03 +08:00
|
|
|
fstype: swap
|
|
|
|
state: absent
|
2023-05-12 01:53:04 +08:00
|
|
|
loop:
|
2018-12-11 18:42:00 +08:00
|
|
|
- swap
|
|
|
|
- none
|
2018-06-21 14:17:03 +08:00
|
|
|
|
2019-02-14 18:35:17 +08:00
|
|
|
# kubelet fails even if ansible_swaptotal_mb = 0
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Check swap
|
2019-02-14 18:35:17 +08:00
|
|
|
command: /sbin/swapon -s
|
|
|
|
register: swapon
|
|
|
|
changed_when: no
|
2021-11-30 16:52:56 +08:00
|
|
|
|
2018-06-21 14:17:03 +08:00
|
|
|
- name: Disable swap
|
2019-02-14 18:35:17 +08:00
|
|
|
command: /sbin/swapoff -a
|
2021-11-30 16:52:56 +08:00
|
|
|
when:
|
|
|
|
- swapon.stdout
|
2021-07-12 15:00:47 +08:00
|
|
|
ignore_errors: "{{ ansible_check_mode }}" # noqa ignore-errors
|
2021-11-27 01:00:51 +08:00
|
|
|
|
|
|
|
- name: Disable swapOnZram for Fedora
|
|
|
|
command: touch /etc/systemd/zram-generator.conf
|
2021-11-30 16:52:56 +08:00
|
|
|
when:
|
|
|
|
- swapon.stdout
|
|
|
|
- ansible_distribution in ['Fedora']
|
2023-05-17 07:38:33 +08:00
|
|
|
ignore_errors: "{{ ansible_check_mode }}" # noqa ignore-errors
|