Add swap memory with ansible

前端 未结 5 2046
醉酒成梦
醉酒成梦 2021-02-05 01:57

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

5条回答
  •  离开以前
    2021-02-05 02:11

    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.

提交回复
热议问题