machine_setup/ansible/roles/bhyve/tasks/freebsd.yaml
2023-04-27 17:05:33 -04:00

66 lines
1.6 KiB
YAML

#
# Create a new VM:
# vm iso 'http://mirror.clarkson.edu/archlinux/iso/2022.01.01/archlinux-2022.01.01-x86_64.iso'
# vm create -t arch -s 50G testvm
# vm install testvm 'archlinux-2022.01.01-x86_64.iso'
#
#
- name: Install packages
package:
name:
- vm-bhyve
- tmux # for interactive consoles
- bhyve-firmware # For UEFI
state: present
- name: Install scripts
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0755
owner: root
group: wheel
loop:
- src: bhyve_netgraph_bridge.bash
dest: /usr/local/bin/bhyve_netgraph_bridge
- name: Create zfs dataset
zfs:
name: "{{ bhyve_dataset }}"
state: present
extra_zfs_properties:
mountpoint: "{{ bhyve_mountpoint }}"
canmount: "{{ bhyve_canmount|default('noauto') }}"
"ta:bemount": "{{ bhyve_bemount|default('on') }}"
- name: Enable bhyve
community.general.sysrc:
name: "{{ item.name }}"
value: "{{ item.value }}"
path: /etc/rc.conf.d/vm
loop:
- name: vm_enable
value: "YES"
- name: vm_dir
value: "zfs:{{ bhyve_dataset }}"
- name: vm_list
value: "{{ bhyve_list|community.general.json_query('[?enabled==`true`].name')|join(' ') }}"
- name: vm_delay
value: "5"
- name: init vm-bhyve
command: vm init
args:
creates: "{{ bhyve_mountpoint }}/.templates"
- name: Install Configuration
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0644
owner: root
group: wheel
loop:
- src: arch.conf
dest: "{{ bhyve_mountpoint }}/.templates/arch.conf"