bugzilla/ansible/roles/host/tasks/setup-swap.yml
Tiara Rodney 883f31932e
init
2026-03-14 05:38:45 +01:00

37 lines
664 B
YAML

---
-
name: Ensure swap exists
command: fallocate -l {{ swap_size | default('2G') }} /swapfile
args:
creates: /swapfile
-
name: Set swap permissions
file:
path: /swapfile
mode: '0600'
-
name: Make swap
command: mkswap /swapfile
args:
creates: /swapfile.swap
-
name: Mark swapfile as initialized
file:
path: /swapfile.swap
state: touch
-
name: Enable swap
command: swapon /swapfile
register: swap_on
failed_when: false
-
name: Add swap to fstab
lineinfile:
path: /etc/fstab
line: "/swapfile none swap sw 0 0"
state: present