From 7c664dfd4526ad1a72dca5adfe96bfd1763b9743 Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 15 Feb 2026 09:42:00 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20ins?= =?UTF-8?q?tallation=20logic=20and=20configure=20settings=20using=20loops?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This refactoring simplifies the installation process by utilizing loops to handle repetitive tasks, improving readability and maintainability of the code. --- tasks/ram.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tasks/ram.yml b/tasks/ram.yml index e10d2be..b248910 100644 --- a/tasks/ram.yml +++ b/tasks/ram.yml @@ -40,7 +40,8 @@ mode: '0644' register: download_archive -- name: Installation Logic +- name: ram | Logic to extract and install log2ram + when: download_archive.changed # noqa: no-handler block: - name: ram | Extract log2ram ansible.builtin.unarchive: @@ -55,23 +56,18 @@ # 'creates' makes the command idempotent by checking for the binary creates: /usr/local/bin/log2ram notify: Restart log2ram - when: download_archive.changed # Configure log2ram -- name: ram | Configure log2ram size +- name: Configure log2ram settings ansible.builtin.lineinfile: path: /etc/log2ram.conf - regexp: '^#?SIZE=' - line: "SIZE={{ log2ram_size }}" + regexp: "{{ item.regexp }}" + line: "{{ item.line }}" backup: yes - notify: Restart log2ram - -- name: ram | Enable rsync sync - ansible.builtin.lineinfile: - path: /etc/log2ram.conf - regexp: '^#?USE_RSYNC=' - line: "USE_RSYNC=true" + loop: + - { regexp: '^#?SIZE=', line: "SIZE={{ log2ram_size }}" } + - { regexp: '^#?USE_RSYNC=', line: "USE_RSYNC=true" } notify: Restart log2ram # Keep journald fully in RAM