15 lines
585 B
YAML
15 lines
585 B
YAML
- block:
|
|
- name: server | system setup | create swapfile
|
|
command: "fallocate -l {{ ansible_facts['memtotal_mb'] / 4 | round }} /swapfile"
|
|
- name: server | system setup | format swapfile
|
|
filesystem:
|
|
fstype: swap
|
|
dev: "/swapfile" # required. Target path to device or image file.
|
|
- name: server | system setup | enable swap
|
|
command: "swapon /swapfile"
|
|
- name: server | system setup | edit fstab
|
|
lineinfile:
|
|
path: "/etc/fstab"
|
|
state: present
|
|
line: "/swapfile none swap sw 0 0"
|
|
when: ansible_facts['memory_mb']['swap']['total'] == '0' |