swap: create swapfile only once
This commit is contained in:
parent
8495c555cc
commit
8de6ab833f
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue