I\'m working on a project where having swap memory on my servers is a needed to avoid some python long running processes to go out of memory and realized for the first time that
Here is the ansible-swap playbook that I use to install 4GB (or whatever I configure group_vars
for dd_bs_size_mb
* swap_count
) of swap space on new servers:
https://github.com/tribou/ansible-swap
I also added a function in my ~/.bash_profile
to help with the task:
# Path to where you clone the repo
ANSIBLE_SWAP_PLAYBOOK=$HOME/dev/ansible-swap
install-swap ()
{
usage='Usage: install-swap HOST';
if [ $# -ne 1 ]; then
echo "$usage";
return 1;
fi;
ansible-playbook $ANSIBLE_SWAP_PLAYBOOK/ansible-swap/site.yml --extra-vars "target=$1"
}
Just make sure to add your HOST
to your ansible inventory first.
Then it's just install-swap HOST
.