|
@@ -4,25 +4,25 @@
|
4
|
4
|
- name: Create swap files
|
5
|
5
|
command: dd if=/dev/zero of={{ '%s%d' | format(swap_file_path, item) }} bs=1024 count={{ swap_file_size }}K
|
6
|
6
|
creates="{{ '%s%d' | format(swap_file_path, item) }}"
|
7
|
|
- loop: "{{ range(1, swap_file_count + 1) }}"
|
|
7
|
+ loop: "{{ range(1, ( swap_file_count | int ) + 1) | list }}"
|
8
|
8
|
|
9
|
9
|
- name: Change swap file permissions
|
10
|
10
|
file: path="{{ '%s%d' | format(swap_file_path, item) }}"
|
11
|
11
|
owner=root
|
12
|
12
|
group=root
|
13
|
13
|
mode=0600
|
14
|
|
- loop: "{{ range(1, swap_file_count + 1) }}"
|
|
14
|
+ loop: "{{ range(1, ( swap_file_count | int ) + 1) | list }}"
|
15
|
15
|
|
16
|
16
|
- name: Check swap file types
|
17
|
17
|
command: file {{ '%s%d' | format(swap_file_path, item) }}
|
18
|
18
|
register: swapfile
|
19
|
|
- loop: "{{ range(1, swap_file_count + 1) }}"
|
|
19
|
+ loop: "{{ range(1, ( swap_file_count | int ) + 1) | list }}"
|
20
|
20
|
|
21
|
21
|
- name: Make swap files
|
22
|
22
|
command: "mkswap {{ '%s%d' | format(swap_file_path, item) }}"
|
23
|
23
|
become: true
|
24
|
24
|
when: swapfile.results[item - 1].stdout.find('swap file') == -1
|
25
|
|
- loop: "{{ range(1, swap_file_count + 1) }}"
|
|
25
|
+ loop: "{{ range(1, ( swap_file_count | int ) + 1) | list }}"
|
26
|
26
|
|
27
|
27
|
- name: Write swap entries in fstab
|
28
|
28
|
mount: name=none
|
|
@@ -32,7 +32,7 @@
|
32
|
32
|
passno=0
|
33
|
33
|
dump=0
|
34
|
34
|
state=present
|
35
|
|
- loop: "{{ range(1, swap_file_count + 1) }}"
|
|
35
|
+ loop: "{{ range(1, ( swap_file_count | int )+ 1) |list }}"
|
36
|
36
|
|
37
|
37
|
- name: Mount swap
|
38
|
38
|
command: "swapon --all"
|