2018-06-21 14:17:03 +08:00
|
|
|
---
|
|
|
|
- name: Remove swapfile from /etc/fstab
|
|
|
|
mount:
|
2018-12-11 18:42:00 +08:00
|
|
|
name: "{{ item }}"
|
2018-06-21 14:17:03 +08:00
|
|
|
fstype: swap
|
|
|
|
state: absent
|
2018-12-11 18:42:00 +08:00
|
|
|
with_items:
|
|
|
|
- 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
|
|
|
|
- name: check swap
|
|
|
|
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
|
|
|
|
- kubelet_fail_swap_on | default(True)
|
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']
|
|
|
|
- kubelet_fail_swap_on | default(True)
|