refactor ♻️: Refactor memory variables and calculations #32

Merged
Jose merged 1 commits from dev into main 2026-02-15 12:50:05 +01:00
3 changed files with 5 additions and 4 deletions

View File

@@ -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) }}"
Review

[Score: 2] Potential performance impact if host_memtotal_mb is missing or incorrectly set and excessive log2ram size allocation occurs. Consider adding a check for the availability of host_memtotal_mb before applying the default value.

[Score: 2] Potential performance impact if `host_memtotal_mb` is missing or incorrectly set and excessive log2ram size allocation occurs. Consider adding a check for the availability of `host_memtotal_mb` before applying the default value.
# Journald RAM usage limit
journald_runtime_max_use: "100M"

View File

@@ -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,

View File

@@ -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