27 lines
514 B
YAML
27 lines
514 B
YAML
---
|
|
- name: Check if /etc/fstab exists
|
|
stat:
|
|
path: "/etc/fstab"
|
|
get_attributes: false
|
|
get_checksum: false
|
|
get_mime: false
|
|
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
|
|
masked: true
|
|
|
|
- name: Disable swap
|
|
command: /sbin/swapoff -a
|