2018-06-21 14:17:03 +08:00
|
|
|
---
|
2024-01-09 00:38:14 +08:00
|
|
|
- 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
|
|
|
|
|
2023-12-07 20:26:21 +08:00
|
|
|
- name: Mask swap.target (persist swapoff)
|
|
|
|
ansible.builtin.systemd_service:
|
|
|
|
name: swap.target
|
|
|
|
masked: true
|
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
|