fix disable swap in centos (#10751)
This commit is contained in:
@ -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)
|
- name: Mask swap.target (persist swapoff)
|
||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
name: swap.target
|
name: swap.target
|
||||||
|
Reference in New Issue
Block a user