Move swap management out of mastodon role and into yttrx role

This commit is contained in:
Waffles
2022-12-26 22:59:02 -08:00
parent 526e28d935
commit 8593bf2e7a
5 changed files with 4 additions and 3 deletions
+2
View File
@@ -1,4 +1,6 @@
---
- import_tasks: swap.yml
- name: Install prometheus node exporter
package:
name: prometheus-node-exporter
+36
View File
@@ -0,0 +1,36 @@
- name: set swap_file variable
set_fact:
swap_file: /{{ swap_space }}.swap
- name: check if swap file exists
stat:
path: "{{ swap_file }}"
register: swap_file_check
- name: create swap file
command: fallocate -l {{ swap_space }} {{ swap_file }}
args:
creates: /{{ swap_file }}
- name: set permissions on swap file
file:
path: "{{ swap_file }}"
mode: 0600
- name: format swap file
command: mkswap {{ swap_file }}
when: not swap_file_check.stat.exists
- name: add to fstab
lineinfile:
dest: /etc/fstab
regexp: "{{ swap_file }}"
line: "{{ swap_file }} none swap sw 0 0"
- name: turn on swap
command: swapon -a
- name: set swapiness
sysctl:
name: vm.swappiness
value: "1"
+2
View File
@@ -0,0 +1,2 @@
---
swap_space: 1G