tofu: GPU-VMs mit allen Karten des Knotens, DHCP über Gast-Agent, Provider für PVE 9
ci / test (push) Successful in 28s
ci / test (push) Successful in 28s
bpg/proxmox ~> 0.116.0 (nur API). Template je Knoten, Speicher je Gast, hostpci dynamisch aus vms.*.gpus, kein Secure Boot (DKMS), Vendor-Snippet für den qemu-guest-agent, Ausgabe ansible_inventory für die DHCP-Adressen. scripts/make-template.sh legt das Ubuntu-24.04-Template mit Prüfsumme an. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e88e0ea46b
commit
ff74c1a7b2
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Ubuntu-24.04-Cloud-Image als VM-Template auf einem Knoten anlegen (Git-Bash auf dem Laptop
|
||||
# oder auf ops). Idempotent: Ein vorhandenes Template bleibt unverändert.
|
||||
#
|
||||
# make-template.sh <knoten> <vmid> [speicher]
|
||||
#
|
||||
# <vmid> laut sites/knaster/proxmox.yaml (cluster.templates), z. B. 9044 für pve44
|
||||
# [speicher] Ziel für Template-Disks (Standard: local-lvm)
|
||||
#
|
||||
# Das Image wird gegen SHA256SUMS von cloud-images.ubuntu.com (HTTPS) geprüft. Kein Secure Boot
|
||||
# (pre-enrolled-keys=0), weil die NVIDIA-DKMS-Module in den GPU-VMs nicht signiert sind.
|
||||
set -euo pipefail
|
||||
|
||||
node=${1:?Aufruf: make-template.sh <knoten> <vmid> [speicher]}
|
||||
vmid=${2:?Aufruf: make-template.sh <knoten> <vmid> [speicher]}
|
||||
storage=${3:-local-lvm}
|
||||
|
||||
ssh -T -o BatchMode=yes "$node" "VMID=$vmid STORAGE=$storage bash -s" <<'REMOTE'
|
||||
set -euo pipefail
|
||||
if qm status "$VMID" >/dev/null 2>&1; then echo "Template $VMID existiert schon auf $(hostname)"; exit 0; fi
|
||||
base=https://cloud-images.ubuntu.com/noble/current
|
||||
img=noble-server-cloudimg-amd64.img
|
||||
dir=/var/lib/vz/import
|
||||
mkdir -p "$dir" && cd "$dir"
|
||||
curl -fsSL -o SHA256SUMS "$base/SHA256SUMS"
|
||||
want=$(awk -v f="*$img" '$2 == f {print $1}' SHA256SUMS)
|
||||
[ -n "$want" ] || { echo "FEHLER: $img fehlt in SHA256SUMS" >&2; exit 1; }
|
||||
if ! echo "$want $img" | sha256sum -c --quiet >/dev/null 2>&1; then
|
||||
curl -fsSL -o "$img" "$base/$img"
|
||||
echo "$want $img" | sha256sum -c --quiet
|
||||
fi
|
||||
qm create "$VMID" --name "ubuntu-2404-tpl-$(hostname)" --ostype l26 --machine q35 --bios ovmf \
|
||||
--cpu host --cores 2 --memory 2048 --scsihw virtio-scsi-single \
|
||||
--efidisk0 "$STORAGE:0,efitype=4m,pre-enrolled-keys=0" \
|
||||
--scsi0 "$STORAGE:0,import-from=$dir/$img,discard=on,ssd=1" \
|
||||
--ide2 "$STORAGE:cloudinit" --boot order=scsi0 --serial0 socket \
|
||||
--net0 virtio,bridge=vmbr0 --agent enabled=1 --tags "knaster;template" >/dev/null
|
||||
qm template "$VMID"
|
||||
echo "Template $VMID auf $(hostname) fertig ($(sha256sum "$img" | cut -c1-12))"
|
||||
REMOTE
|
||||
Reference in New Issue
Block a user