fix: unmount swap before changing it
This commit is contained in:
parent
2423e9ecda
commit
8644006b8e
@ -1,9 +1,16 @@
|
||||
---
|
||||
- when: not (swap_enabled | bool) or swap_size | int > (ansible_swaptotal_mb | int) + 1
|
||||
block:
|
||||
- name: Disable active swap
|
||||
- name: Disable swap
|
||||
ansible.builtin.shell: "test -f {{ swap_path }} && swapoff {{ swap_path }} || true"
|
||||
|
||||
- name: Unmount swap file
|
||||
ansible.posix.mount:
|
||||
src: "{{ swap_path }}"
|
||||
path: none
|
||||
fstype: swap
|
||||
state: absent
|
||||
|
||||
- name: Remove swap file
|
||||
ansible.builtin.file:
|
||||
path: "{{ swap_path }}"
|
||||
@ -35,6 +42,6 @@
|
||||
fstype: swap
|
||||
state: present
|
||||
|
||||
- name: Enable swap file
|
||||
- name: Enable swap
|
||||
ansible.builtin.command: "swapon -a"
|
||||
changed_when: False
|
||||
|
Loading…
Reference in New Issue
Block a user