diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 1b7a252..011a786 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -69,3 +69,21 @@ - name: Add update line to update script shell: echo apt-get update && apt-get upgrade -y && apt-get clean && apt-get autoclean && apt-get autoremove -y && apt-get update >> /etc/cron.daily/update.sh + +- name: Allocate swap file + shell: fallocate -l 4G /swapfile + +- name: Secure swapfile + shell: chmod 600 /swapfile + +- name: Make swap file + shell: mkswap /swapfile + +- name: Enable swap file + shell: swapon /swapfile + +- name: Fix swappiness + shell: echo "sysctl vm.swappiness=10" >> /etc/sysctl.conf + +- name: Fix cache pressure + shell: echo "sysctl vm.vfs_cache_pressure=50" >> /etc/sysctl.conf