diff --git a/tasks/swap.yml b/tasks/swap.yml index 5822bc8021..01a9f0c6ca 100644 --- a/tasks/swap.yml +++ b/tasks/swap.yml @@ -6,21 +6,22 @@ file: path: "{{ swap_file_path }}" state: touch + register: swap_touch - name: On BTRFS we need NoCOW file: path: "{{ swap_file_path }}" attr: +C + when: swap_touch.changed - name: Create swap file command: cmd: "dd if=/dev/zero of={{ swap_file_path }} bs=1024 count={{ swap_file_size_mb }}k" - creates: "{{ swap_file_path }}" + when: swap_touch.changed tags: - swap.file.create - swap - - name: Change swap file permissions file: path="{{ swap_file_path }}" owner=root