You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
514 B

  1. ---
  2. - name: Check if /etc/fstab exists
  3. stat:
  4. path: "/etc/fstab"
  5. get_attributes: false
  6. get_checksum: false
  7. get_mime: false
  8. register: fstab_file
  9. - name: Remove swapfile from /etc/fstab
  10. ansible.posix.mount:
  11. name: "{{ item }}"
  12. fstype: swap
  13. state: absent
  14. loop:
  15. - swap
  16. - none
  17. when: fstab_file.stat.exists
  18. - name: Mask swap.target (persist swapoff)
  19. ansible.builtin.systemd_service:
  20. name: swap.target
  21. masked: true
  22. - name: Disable swap
  23. command: /sbin/swapoff -a