From bbb133a0a55f1548308d6e8fa0590eb5e8b4a8a6 Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 15 Feb 2026 18:43:12 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20log?= =?UTF-8?q?2ram=20size=20calculation=20for=20integer=20values=20and=20impr?= =?UTF-8?q?ove=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This refactoring ensures that the log2ram size calculation always results in an integer value, enhancing precision. Additionally, it improves code readability by simplifying complex expressions. --- tasks/ram.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tasks/ram.yml b/tasks/ram.yml index a6f6e86..eed1fd6 100644 --- a/tasks/ram.yml +++ b/tasks/ram.yml @@ -10,11 +10,14 @@ - name: ram | Calculate log2ram size ansible.builtin.set_fact: - _calculated_size_mb: "{{ (ansible_memtotal_mb * log2ram_ram_percent / 100) | int }}" log2ram_size_mb: >- {{ - [log2ram_min_size_mb, - [_calculated_size_mb, log2ram_max_size_mb] | min + [ + log2ram_min_size_mb | int, + [ + (ansible_memtotal_mb | int * log2ram_ram_percent | int / 100) | int, + log2ram_max_size_mb | int + ] | min ] | max }}