fix disable swap in centos (#10751)

pull/10511/head
Kay Yan 2024-01-09 00:38:14 +08:00 committed by GitHub
parent ddf5c6ee12
commit 2e8b72e278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -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