Skip to content

Commit

Permalink
fix disable swap in centos (#10751)
Browse files Browse the repository at this point in the history
  • Loading branch information
yankay authored Jan 8, 2024
1 parent ddf5c6e commit 2e8b72e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions roles/kubernetes/preinstall/tasks/0010-swapoff.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
---
- name: Check if /etc/fstab exists
stat:
path: "/etc/fstab"
get_attributes: no
get_checksum: no
get_mime: no
register: fstab_file

- name: Remove swapfile from /etc/fstab
ansible.posix.mount:
name: "{{ item }}"
fstype: swap
state: absent
loop:
- swap
- none
when: fstab_file.stat.exists

- name: Mask swap.target (persist swapoff)
ansible.builtin.systemd_service:
name: swap.target
Expand Down

0 comments on commit 2e8b72e

Please sign in to comment.