#!/usr/bin/env bash # # Create a VM on Proxmox for a new llmgw node. # # Run on the Proxmox host. It does the half of onboarding that is about # hardware; onboard-node.sh does the half that is about identity, and the two # are separate because they are done by different people with different access. # # Idempotent only in the sense that it refuses to touch an existing VMID. A node # that already exists is not something a provisioning script should have an # opinion about. set -euo pipefail usage() { cat >&2 </dev/null 2>&1; then echo "VM $VMID already exists. Pick a free id; this script will not adopt one." >&2 exit 1 fi [ -f "$IMAGE" ] || { echo "no cloud image at $IMAGE" >&2; exit 1; } echo "creating $NAME as VM $VMID at $IP" qm create "$VMID" \ --name "$NAME" --cores "$CORES" --memory "$MEMORY" --cpu "$CPU" \ --net0 "virtio,bridge=$BRIDGE" --ostype l26 --agent enabled=1 # Imported rather than installed: a cloud image plus cloud-init is the whole # reason a node takes a minute to build instead of an afternoon. qm importdisk "$VMID" "$IMAGE" "$STORAGE" >/dev/null qm set "$VMID" --scsihw virtio-scsi-pci --scsi0 "$STORAGE:vm-$VMID-disk-0,discard=on,ssd=1" >/dev/null qm disk resize "$VMID" scsi0 "${DISK}G" >/dev/null qm set "$VMID" --ide2 "$STORAGE:cloudinit" --boot order=scsi0 >/dev/null qm set "$VMID" \ --ipconfig0 "ip=$IP,gw=$GW" \ --nameserver "$GW 8.8.8.8" \ --ciuser "$USER" \ --sshkeys "$SSHKEYS" >/dev/null qm start "$VMID" echo "started. cloud-init takes a minute; then run onboard-node.sh from the CA host."