From 2423e9ecda65ac5a5c5c761f80a8801ea7364cd0 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 17 Apr 2024 14:45:29 +0200 Subject: [PATCH] fix: fix condition to create swap file --- tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index ec39a92..85b6afe 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,5 @@ --- -- when: swap_size | int > (ansible_swaptotal_mb | int) + 1 or not (swap_enabled | bool) +- when: not (swap_enabled | bool) or swap_size | int > (ansible_swaptotal_mb | int) + 1 block: - name: Disable active swap ansible.builtin.shell: "test -f {{ swap_path }} && swapoff {{ swap_path }} || true" @@ -9,7 +9,9 @@ path: "{{ swap_path }}" state: absent -- when: swap_size | int > (ansible_swaptotal_mb | int) + 1 +- when: + - swap_enabled | bool + - swap_size | int > (ansible_swaptotal_mb | int) + 1 block: - name: Create swap file ansible.builtin.command: "fallocate -l {{ swap_size }}M {{ swap_path }}"