machine_setup/ansible/roles/bhyve/tasks/freebsd.yaml

55 lines
1.3 KiB
YAML
Raw Normal View History

2022-11-01 22:53:03 +00:00
#
# 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: 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') }}"
2022-11-01 23:06:44 +00:00
- 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
2022-11-01 23:33:03 +00:00
value: "5"
2022-11-01 23:06:44 +00:00
- 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"