-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to create swap, updated README, resolves #14.
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
- 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 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
|
||
create_swap_file: no | ||
swap_file_path: /swapfile | ||
swap_file_size_kb: 512 |