Last active
August 29, 2015 14:20
-
-
Save rjsalts/72f203cdadfd226776a4 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: Change the swap to given size in gigabytes | |
hosts: all | |
user: root | |
vars: | |
size: 4 | |
tasks: | |
- name: find existing swap size | |
shell: lvs --noheadings --separator , --units g | grep swap_1 | cut -f 4 -d , | |
register: swap_size | |
- name: disable swap | |
command: swapoff -a | |
when: swap_size.stdout != "{{ size }}.00g" | |
notify: activate swap | |
- name: resize swap lvol | |
lvol: vg={{ ansible_hostname }}-vg lv=swap_1 size={{ size }}G force=yes | |
notify: mkswap | |
handlers: | |
- name: mkswap | |
command: mkswap /dev/{{ansible_hostname}}-vg/swap_1 | |
- name: activate swap | |
command: swapon -a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment