-
-
Save drybjed/7dddfa323f9d877c024a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: ensure swap file is allocated | |
command: dd if=/dev/zero of=/swapfile bs=1M count={{ common_swap_size }} creates=/swapfile | |
when: ansible_swaptotal_mb < 1 | |
register: swapfile_init | |
- name: ensure swap file is created | |
command: mkswap /swapfile | |
when: swapfile_init is defined and swapfile_init.changed | |
- name: ensure swap file is added to fstab | |
action: lineinfile dest=/etc/fstab regexp="swapfile" line="/swapfile none swap sw 0 0" state=present | |
when: swapfile_init is defined and swapfile_init.changed | |
- name: ensure swap file is enabled | |
command: swapon -a | |
when: swapfile_init is defined and swapfile_init.changed | |
- name: ensure swappiness is set | |
shell: echo 0 | sudo tee /proc/sys/vm/swappiness | |
when: swapfile_init is defined and swapfile_init.changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment