swap: create swapfile only once

This commit is contained in:
Jakub Kadlcik 2022-01-23 21:45:30 +01:00
parent 8495c555cc
commit 8de6ab833f

View file

@ -6,21 +6,22 @@
file: file:
path: "{{ swap_file_path }}" path: "{{ swap_file_path }}"
state: touch state: touch
register: swap_touch
- name: On BTRFS we need NoCOW - name: On BTRFS we need NoCOW
file: file:
path: "{{ swap_file_path }}" path: "{{ swap_file_path }}"
attr: +C attr: +C
when: swap_touch.changed
- name: Create swap file - name: Create swap file
command: command:
cmd: "dd if=/dev/zero of={{ swap_file_path }} bs=1024 count={{ swap_file_size_mb }}k" 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: tags:
- swap.file.create - swap.file.create
- swap - swap
- name: Change swap file permissions - name: Change swap file permissions
file: path="{{ swap_file_path }}" file: path="{{ swap_file_path }}"
owner=root owner=root