diff --git a/all/mount/tasks/main.yml b/all/mount/tasks/main.yml index eee037b130292b5b3b2263dd55b944f42c45fa93..0e5fd31aaf049840a94cd8c3041a6667cfd48a1d 100644 --- a/all/mount/tasks/main.yml +++ b/all/mount/tasks/main.yml @@ -15,6 +15,14 @@ loop: "{{ lookup('dict', drives) }}" when: drives is defined and item.value.fstype != "swap" +- name: Ensure swap entry is present in /etc/fstab + ansible.builtin.lineinfile: + path: /etc/fstab + state: present + line: "UUID={{ item.value.uuid }} none swap sw 0 0" + loop: "{{ lookup('dict', drives) }}" + when: drives is defined and item.value.fstype == "swap" + - name: Enable swap partition ansible.builtin.command: cmd: "swapon UUID={{ item.value.uuid }}"