Add swapfile to both hosts.
This commit is contained in:
parent
756b121a2b
commit
f7d02fdd20
|
@ -0,0 +1,16 @@
|
|||
{% set swapfile = salt['pillar.get']('swapfile', {}) %}
|
||||
{% set size = swapfile.get('size', grains["mem_total"]) %}
|
||||
{% set path = swapfile.get('path', '/swapfile') %}
|
||||
|
||||
{{ path }}:
|
||||
cmd.run:
|
||||
- name: |
|
||||
swapon --show=NAME --noheadings | grep -q "^{{ path }}$" && swapoff {{ path }}
|
||||
rm -f {{ path }}
|
||||
fallocate -l {{ size }}M {{ path }}
|
||||
chmod 0600 {{ path }}
|
||||
mkswap {{ path }}
|
||||
- unless: bash -c '[[ $(($(stat -c %s {{ path }}) / 1024**2)) = {{ size }} ]]'
|
||||
|
||||
mount.swap:
|
||||
- persist: true
|
|
@ -4,6 +4,7 @@ base:
|
|||
|
||||
'hedwig.lunch.org.uk':
|
||||
- debian
|
||||
- swapfile
|
||||
- apache
|
||||
- mariadb
|
||||
- backup
|
||||
|
@ -18,6 +19,7 @@ base:
|
|||
|
||||
'scabbers.lunch.org.uk':
|
||||
- debian
|
||||
- swapfile
|
||||
- certificates
|
||||
- apache
|
||||
- backup
|
||||
|
|
Loading…
Reference in New Issue