-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.yml
More file actions
39 lines (34 loc) · 1.13 KB
/
main.yml
File metadata and controls
39 lines (34 loc) · 1.13 KB
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
---
#
# Since these tasks rely on each other in a sequential fashion we disable the
# no-handler test for ansible-lint for tasks that are dependent on a previous
# task's completion.
#
- name: Allocate swapfile
ansible.builtin.command:
cmd: "fallocate --length {{ swap_swapfile_size }} {{ swap_swapfile_location }}"
creates: "{{ swap_swapfile_location }}"
register: swap_allocate_swapfile
- name: Set swapfile permissions
ansible.builtin.file:
mode: u=rw,g=,o=
path: "{{ swap_swapfile_location }}"
- name: Create swapfile
ansible.builtin.command: # noqa no-handler
cmd: mkswap {{ swap_swapfile_location }}
changed_when: swap_create_swapfile.rc == 0
register: swap_create_swapfile
when: swap_allocate_swapfile is changed
- name: Enable swapfile
ansible.builtin.command: # noqa no-handler
cmd: swapon {{ swap_swapfile_location }}
changed_when: swap_enable_swapfile.rc == 0
register: swap_enable_swapfile
when: swap_create_swapfile is changed
- name: Add swapfile to /etc/fstab
ansible.posix.mount:
fstype: swap
name: none
opts: sw
src: "{{ swap_swapfile_location }}"
state: present