swap and sysctl tasks added

if swap not enabled, enable swap
set vm.swappiness and vm.vfs_cache_pressure on servers
This commit is contained in:
2022-02-24 23:47:09 +01:00
parent f762d0c964
commit c4640eae0e
4 changed files with 25 additions and 1 deletions

View File

@@ -1,3 +1,2 @@
rene_password:
swappiness_value: 5
root_home: "{{ lookup('env','HOME') }}"

View File

@@ -0,0 +1,15 @@
- block:
- name: server | system setup | create swapfile
command: "fallocate -l {{ ansible_facts['memtotal_mb'] / 4 | round }} /swapfile"
- name: server | system setup | format swapfile
filesystem:
fstype: swap
dev: "/swapfile" # required. Target path to device or image file.
- name: server | system setup | enable swap
command: "swapon /swapfile"
- name: server | system setup | edit fstab
lineinfile:
path: "/etc/fstab"
state: present
line: "/swapfile none swap sw 0 0"
when: ansible_facts['memory_mb']['swap']['total'] == '0'

View File

@@ -0,0 +1,9 @@
- name: server | system setup | sysctl
sysctl:
name: "{{ item.key }}"
value: "{{ item.value }}"
state: present
reload: yes
loop:
- { key: "vm.swappiness", value: "10"}
- { key: "vm.vfs_cache_pressure", value: "50"}

View File

@@ -0,0 +1 @@
swappiness_value: 5