diff --git a/tasks/configure_swap.yml b/tasks/configure_swap.yml index caebbbff7dcfd3deb189d7fc034ba594f9afa784..2862af15d9b7acb26811c89a82894ae1e301f662 100644 --- a/tasks/configure_swap.yml +++ b/tasks/configure_swap.yml @@ -15,7 +15,6 @@ when: ansible_os_family == "Debian" # RHEL part is based on https://www.techrepublic.com/article/how-to-enable-zram-rocky-linux/ -# Note: all that udev stuff from that guide doesn't work. We'll use CLI commands. # More docu on zram at https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html - name: configure zram based swap (RedHat) block: @@ -41,6 +40,12 @@ create: true line: "options zram num_devices=1" mode: "0644" + - name: configure udev to initialise zram device on bootup + ansible.builtin.lineinfile: + path: "/etc/udev/rules.d/99-zram.rules" + create: true + line: "KERNEL==\"zram0\", ATTR{disksize}=\"{{ ( ansible_facts.memtotal_mb / 2 ) | round | int }}M\",TAG+=\"systemd\"" + mode: "0644" - name: find out if zram Kernel module has been loaded already ansible.builtin.command: "lsmod" register: kernel_modules