Created
March 16, 2015 14:52
swap ansible
This file contains hidden or 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: Create swap file | |
command: dd if=/dev/zero of={{ swap_file_path }} bs=1024 count={{ swap_file_size_kb }}k | |
creates="{{ swap_file_path }}" | |
tags: | |
- swap.file.create | |
- name: Change swap file permissions | |
file: path="{{ swap_file_path }}" | |
owner=root | |
group=root | |
mode=0600 | |
tags: | |
- swap.file.permissions | |
- name: "Check swap file type" | |
command: file {{ swap_file_path }} | |
register: swapfile | |
tags: | |
- swap.file.mkswap | |
- name: Make swap file | |
command: "sudo mkswap {{ swap_file_path }}" | |
when: swapfile.stdout.find('swap file') == -1 | |
tags: | |
- swap.file.mkswap | |
- name: Write swap entry in fstab | |
mount: name=none | |
src={{ swap_file_path }} | |
fstype=swap | |
opts=sw | |
passno=0 | |
dump=0 | |
state=present | |
tags: | |
- swap.fstab | |
- name: Mount swap | |
command: "swapon {{ swap_file_path }}" | |
when: ansible_swaptotal_mb < 1 | |
tags: | |
- swap.file.swapon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment