--- - name: Disable swap ansible.builtin.shell: "test -f {{ swap_path }} && swapoff {{ swap_path }} || true" changed_when: False - 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 }}" state: absent