From c3327cd681e284ad5a9264637d2f319e1a89af7f Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 15 Feb 2026 12:45:26 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20mem?= =?UTF-8?q?ory=20variables=20and=20calculations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renamed `_total_ram_mb` to `log2ram_host_memtotal_mb` and updated the calculation accordingly. Updated variable names for memory checks in swap task. --- defaults/main.yml | 1 + tasks/ram.yml | 4 ++-- tasks/swap.yml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 1c18c96..56f713a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -37,6 +37,7 @@ log2ram_ram_percent: 10 log2ram_min_size_mb: 128 log2ram_max_size_mb: 1024 +log2ram_host_memtotal_mb: "{{ host_memtotal_mb | default(4086) }}" # Journald RAM usage limit journald_runtime_max_use: "100M" diff --git a/tasks/ram.yml b/tasks/ram.yml index 366f592..f8f8937 100644 --- a/tasks/ram.yml +++ b/tasks/ram.yml @@ -6,8 +6,8 @@ - name: ram | Calculate log2ram size ansible.builtin.set_fact: - _total_ram_mb: "{{ ansible_memtotal_mb }}" - _calculated_size_mb: "{{ (ansible_memtotal_mb * log2ram_ram_percent / 100) | int }}" + _total_ram_mb: "{{ log2ram_host_memtotal_mb }}" + _calculated_size_mb: "{{ (log2ram_host_memtotal_mb * log2ram_ram_percent / 100) | int }}" log2ram_size_mb: >- {{ [log2ram_min_size_mb, diff --git a/tasks/swap.yml b/tasks/swap.yml index adf3fb2..2271650 100644 --- a/tasks/swap.yml +++ b/tasks/swap.yml @@ -15,7 +15,7 @@ ansible.builtin.command: swapoff -a when: - proxmox_disable_swap - - ansible_memtotal_mb >= proxmox_min_ram_mb_for_no_swap + - log2ram_host_memtotal_mb >= proxmox_min_ram_mb_for_no_swap - active_swaps.stdout | bool changed_when: active_swaps.stdout | bool @@ -26,4 +26,4 @@ replace: '\1# \2' when: - proxmox_disable_swap - - ansible_memtotal_mb >= proxmox_min_ram_mb_for_no_swap + - log2ram_host_memtotal_mb >= proxmox_min_ram_mb_for_no_swap