forked from Overclock-Validator/autoclock-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swap.yaml
49 lines (43 loc) · 1.03 KB
/
swap.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
- name: Create swap file
become: true
become_user: root
command: dd if=/dev/zero of=/mnt/swapfile bs=1024 count={{ swap_mb }}k
creates="/mnt/swapfile"
- name: Change swap file permissions
become: true
become_user: root
file: path="/mnt/swapfile"
owner=root
group=root
mode=0600
- name: Check swap file type
become: true
become_user: root
command: file /mnt/swapfile
register: swapfile
- name: Make swap file
become: true
become_user: root
command: "sudo mkswap /mnt/swapfile"
when: swapfile.stdout.find('swap file') == -1
- name: Write swap entry in fstab
become: true
become_user: root
mount: name=none
src=/mnt/swapfile
fstype=swap
opts=sw
passno=0
dump=0
state=present
- name: swap check
become: true
become_user: root
ignore_errors: yes
shell: swapon -show | grep /mnt/swapfile
register: swap_check
- name: Mount swap
become: true
become_user: root
command: "swapon /mnt/swapfile"
when: swap_check.rc != 0