From f3980dc821f68bf5ba04bb28806c93d95388b7eb Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 13 Jun 2023 14:13:55 -0400 Subject: [PATCH] Add support for both NAT and RAW network interfaces in virtual machine. This is used so metallb can announce public ip addresses. --- .../bhyve/files/bhyve_netgraph_bridge.bash | 83 ++++++++++++------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash b/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash index 6928836..6c3d2b2 100644 --- a/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash +++ b/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash @@ -21,17 +21,22 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere /vm/iso/FreeBSD-13.2-RELEASE-amd64-bootonly.iso # doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere +: ${VERBOSE:="NO"} # or YES : ${CPU_CORES:="1"} : ${MEMORY:="1G"} -: ${NETWORK:="NAT"} # or RAW +: ${NETWORK:="NAT"} # or RAW or BOTH : ${IP_RANGE:="10.215.1.1/24"} # Ignored for RAW networks : ${INTERFACE_NAME:="jail_nat"} # or the external interface like lagg0 for RAW networks : ${BRIDGE_NAME:="bridge_$INTERFACE_NAME"} # or bridge_raw for RAW networks : ${VNC_ENABLE:="NO"} : ${VNC_LISTEN:="127.0.0.1:5900"} +if [ "$VERBOSE" = "YES" ]; then + set -x +fi + function main { - cmd="$1" + local cmd="$1" shift 1 if [ "$cmd" = "create-disk" ]; then create_disk "${@}" @@ -50,9 +55,9 @@ function die { } function create_disk { - zfs_path="$1" - mount_path="$2" - gigabytes="$3" + local zfs_path="$1" + local mount_path="$2" + local gigabytes="$3" zfs create -o "mountpoint=$mount_path" "$zfs_path" cp /usr/local/share/edk2-bhyve/BHYVE_UEFI_VARS.fd "${mount_path}/" tee "${mount_path}/settings" <