From 83febca09a5f39d8aaae06ccc8d4a97f882d6795 Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 15 Feb 2026 09:27:03 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20tas?= =?UTF-8?q?k=20structure=20and=20update=20configuration=20method=20in=20`r?= =?UTF-8?q?am.yml`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit refactors the task structure in `ram.yml` and updates the configuration method to improve readability and maintainability. --- handlers/main.yml | 3 --- tasks/ram.yml | 45 ++++++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 0c41bba..3932733 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -31,6 +31,3 @@ ansible.builtin.systemd: name: systemd-journald state: restarted - -- name: Reload sysctl - ansible.builtin.command: sysctl --system diff --git a/tasks/ram.yml b/tasks/ram.yml index 2dea592..e10d2be 100644 --- a/tasks/ram.yml +++ b/tasks/ram.yml @@ -40,21 +40,22 @@ mode: '0644' register: download_archive -- name: ram | Extract log2ram - ansible.builtin.unarchive: - src: "/tmp/log2ram.tar.gz" - dest: "/tmp" - remote_src: yes - when: download_archive.changed +- name: Installation Logic + block: + - name: ram | Extract log2ram + ansible.builtin.unarchive: + src: "/tmp/log2ram.tar.gz" + dest: "/tmp" + remote_src: yes -- name: ram | Install log2ram - ansible.builtin.command: bash install.sh - args: - chdir: "/tmp/log2ram-master" - # 'creates' makes the command idempotent by checking for the binary - creates: /usr/local/bin/log2ram + - name: ram | Install log2ram + ansible.builtin.command: bash install.sh + args: + chdir: "/tmp/log2ram-master" + # 'creates' makes the command idempotent by checking for the binary + creates: /usr/local/bin/log2ram + notify: Restart log2ram when: download_archive.changed - notify: Restart log2ram # Configure log2ram @@ -93,11 +94,13 @@ # Enable log2ram on boot - name: ram | Configure memory tuning sysctl - ansible.builtin.copy: - dest: /etc/sysctl.d/99-proxmox-memory.conf - content: | - vm.swappiness = {{ vm_swappiness }} - vm.dirty_ratio = {{ vm_dirty_ratio }} - vm.dirty_background_ratio = {{ vm_dirty_background_ratio }} - mode: '0644' - notify: Reload sysctl + ansible.posix.sysctl: + name: "{{ item.name }}" + value: "{{ item.value }}" + state: present + sysctl_file: /etc/sysctl.d/99-proxmox-memory.conf + reload: yes + loop: + - { name: 'vm.swappiness', value: "{{ vm_swappiness }}" } + - { name: 'vm.dirty_ratio', value: "{{ vm_dirty_ratio }}" } + - { name: 'vm.dirty_background_ratio', value: "{{ vm_dirty_background_ratio }}" }