ansible/roles/bhyve-s6/templates/bhyve/run.j2

46 lines
1.3 KiB
Django/Jinja

#!/usr/local/bin/execlineb -P
# {{ ansible_managed }}
s6-envdir ./env
multisubstitute {
importas -i -u NAME NAME
importas -i -u -s ORDER ORDER
importas -i -u RAM RAM
importas -i -u ROM ROM
importas -i -u CPUS CPUS
importas -i -u NIC NIC
importas -i -u COM COM
importas -i -u PORT PORT
importas -i -u PASS PASS
}
backtick -n AHCI {
forx X { $ORDER }
importas X X
importas Y $X
echo -n ,$Y
}
importas -i -u AHCI AHCI
foreground { if { test -e "/dev/vmm/${NAME}" } bhyvectl --vm="${NAME}" --destroy }
foreground { /etc/rc.d/netif start "${NIC}" }
foreground { fdmove -c 1 2 echo "bhyve-${NAME}: Starting VM ${NAME} with ${CPUS} CPUs, ${RAM} RAM, COM on ${COM}, NIC ${NIC} and VNC port ${PORT}." }
s6-notifyoncheck -d -w 100 -n 70
fdmove -c 2 1
bhyve -c "{{ item.0.cpus }}" -m "{{ item.0.ram }}" -w -A -P -H
-s "0,amd_hostbridge"
-s "2:0,ahci${AHCI}"
-s "3,virtio-net,${NIC}"
-s "4,virtio-rnd"
{% for disk in item.0.disks if disk.virtio|default(False) -%}
-s "{{ disk.virtio_slot }},virtio,/dev/zvol/{{ bhyve_pool }}/bhyve/guests/{{ item.0.name }}/{{ disk.name }}"
{% endfor -%}
{% if item.0.password is defined -%}
-s "29,fbuf,tcp=[::1]:${PORT},w=800,h=600,password=${PASS}"
{% endif -%}
-s "31,lpc"
-l "com1,/dev/${COM}"
-l "bootrom,${ROM}"