forked from nodejs/build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible: add swapfile creation for FreeBSD
- Loading branch information
1 parent
c7e6565
commit 83d9209
Showing
2 changed files
with
40 additions
and
1 deletion.
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,39 @@ | ||
--- | ||
|
||
# | ||
# FreeBSD | ||
# | ||
|
||
# Assumes swap_file_size_mb has been set. | ||
- name: create swapfile | ||
ansible.builtin.command: | ||
cmd: dd if=/dev/zero of=/{{ swap_file }} bs=1M count={{ swap_file_size_mb }} | ||
creates: "{{ swap_file }}" | ||
become: yes | ||
become_user: root | ||
register: swap_create | ||
|
||
- name: set swapfile permissions | ||
ansible.builtin.file: | ||
mode: 0600 | ||
owner: root | ||
path: "{{ swap_file }}" | ||
|
||
- name: set up swap area | ||
ansible.builtin.command: | ||
cmd: mdconfig -a -t vnode -f {{ swap_file }} -u 0 | ||
when: swap_create.changed | ||
|
||
- name: enable swap | ||
ansible.builtin.command: | ||
cmd: swapon /dev/md0 | ||
when: swap_create.changed | ||
|
||
- name: add swap to fstab | ||
ansible.posix.mount: | ||
fstype: swap | ||
opts: "sw,file={{ swap_file }},late" | ||
path: none | ||
src: md0 | ||
state: present | ||
when: swap_create.changed |