add swapfile for lewis
This commit is contained in:
parent
3867b0983f
commit
43ce9b0b40
2 changed files with 28 additions and 0 deletions
|
@ -65,3 +65,30 @@
|
|||
hosts: lewis
|
||||
roles:
|
||||
- {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
|
||||
|
|
1
ansible/inventory/host_vars/lewis/swap.yml
Normal file
1
ansible/inventory/host_vars/lewis/swap.yml
Normal file
|
@ -0,0 +1 @@
|
|||
swapfile_loc: /swapfile.img
|
Reference in a new issue