From f46037540bf81a3c4e56e5f3c8126ffc1644fb4f Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Sun, 24 Jan 2016 17:29:38 -0500 Subject: [PATCH] Added swapfile to vps --- roles/common/tasks/main.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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