Skip to content

Commit

Permalink
ansible: add swapfile creation for FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlau committed Oct 4, 2024
1 parent 7172ec3 commit ba594fe
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ansible/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ hosts:
fedora40-x64-2: {ip: 162.243.187.89}
freebsd12-x64-1: {ip: 45.55.90.237, user: freebsd}
freebsd12-x64-2: {ip: 107.170.28.213, user: freebsd}
freebsd13-x64-1: {ip: 138.197.25.49, user: freebsd}
freebsd13-x64-1: {ip: 138.197.25.49, user: freebsd, swap_file_size_mb: 2048}
rhel8-x64-1: {ip: 161.35.139.78, build_test_v8: yes, swap_file_size_mb: 2048}
rhel9-x64-1: {ip: 134.122.12.240, swap_file_size_mb: 2048}
ubuntu2204_docker-x64-1: {ip: 134.209.55.216}
Expand Down
39 changes: 39 additions & 0 deletions ansible/roles/bootstrap/tasks/partials/freebsd.yml
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

0 comments on commit ba594fe

Please sign in to comment.