zmgr/create_ipxe_vm.sh
Till Wegmueller abdce9c927
Add zmgr: illumos zone manager with IPAM and flat-file registry
Rust CLI that creates/destroys/imports illumos zones from KDL template
configs with automatic IP allocation from named pools. Registry lives
under /etc/zmgr as flat KDL files — zone entries double as the IPAM
ledger. Includes default templates for ipkg (OI) and nlipkg (OFL)
brands, matching the existing shell scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 12:14:09 +01:00

66 lines
1 KiB
Bash
Executable file

#!/usr/bin/bash
set -ex
ZONE=$1
IP_ADDRESS_CIDR="${2}/16"
NICNAME="${ZONE}0"
INTERNALSTUB="oinetint0"
GATEWAY="10.1.0.1"
RAM="16G"
VCPUS="8"
DISK="60G"
ISO="/vm/iso/ipxe-oi-internal.iso"
if ! dladm show-vnic $NICNAME > /dev/null; then
dladm create-vnic -l $INTERNALSTUB $NICNAME
fi
if ! zfs get name rpool/vm/${ZONE}d0 > /dev/null;then
zfs create -V ${DISK} rpool/vm/${ZONE}d0
fi
cat <<EOF | zonecfg -z $ZONE
create -b
set zonepath=/zones/$ZONE
set brand=bhyve
set autoboot=true
set ip-type=exclusive
add fs
set dir="/vm/iso"
set special="/vm/iso"
set type="lofs"
add options ro
add options nodevices
end
add net
set physical="$NICNAME"
end
add device
set match="/dev/zvol/rdsk/rpool/vm/${ZONE}d0"
end
add attr
set name="bootdisk"
set type="string"
set value="rpool/vm/${ZONE}d0"
end
add attr
set name="ram"
set type="string"
set value="${RAM}"
end
add attr
set name="vcpus"
set type="string"
set value="${VCPUS}"
end
add attr
set name="cdrom"
set type="string"
set value="${ISO}"
end
EOF
zoneadm -z $ZONE install
zoneadm -z $ZONE boot
zlogin -C $ZONE