add swapfile for lewis

This commit is contained in:
Pim Kunis 2023-08-12 12:13:49 +02:00
parent 3867b0983f
commit 43ce9b0b40
2 changed files with 28 additions and 0 deletions

View file

@ -65,3 +65,30 @@
hosts: lewis hosts: lewis
roles: roles:
- {role: borg, tags: borg} - {role: borg, tags: borg}
- hosts: lewis
tasks:
- name: Check if swap file exists
stat:
path: "{{ swapfile_loc }}"
register: swapfile
- name: Create swap file
block:
- name: Create file
command:
cmd: "dd if=/dev/zero of={{ swapfile_loc }} bs=1024 count=2M"
- name: Format swap file
command:
cmd: "mkswap {{ swapfile_loc }}"
when: not swapfile.stat.exists
- name: Mount swap file
mount:
src: "{{ swapfile_loc }}"
path: swap
fstype: swap
opts: sw
state: present

View file

@ -0,0 +1 @@
swapfile_loc: /swapfile.img