Builds an isolated bridge, a head node with a management and a cluster NIC, and N diskless compute nodes that PXE boot from it - the shape scripts/00-proxmox-provision.sh creates by hand, parameterised per tenant. Applied and destroyed cleanly against the real Proxmox, twice. MACs are derived rather than generated: BC:24:11:E0:<tenant>:<index>. Warewulf matches nodes by MAC, so a MAC that changed on re-apply would orphan the node's registration and it would never boot again. VMIDs likewise come from a recorded base, not from Proxmox nextid, which races. The bridge is deliberately not the provider's resource. proxmox_network_linux_ bridge writes the stanza and then reads the live interface back before anything has applied it, so creation fails outright. Proxmox applies pending network changes with "ifreload -a", which reloads every interface - a bad trade on a hypervisor carrying other people's guests, and fatal on a host where any unrelated stanza is broken. This one is: an interface here holds 10.0.0.1/8, the same address as the default gateway, so ifreload always exits non-zero while re-adding the default route. The bridge is therefore managed with an explicit remote-exec that appends the stanza, runs ifquery -a to prove the file still parses, and brings up only the new interface with ifup. Idempotent, so an interrupted run recovers by re-running; the destroy path verifies the interface is really gone, since a leaked bridge is a leaked subnet. Three things found only by running it against real hardware: - The token's role needs SDN.Use, or attaching a VM to a new bridge fails with a 403 that does not mention SDN anywhere obvious. - The cloud image must sit in a datastore with the "import" content type (local:import/...); an image in the ISO directory is rejected with "unable to parse directory volume name". - The first version wrote its comment into /etc/network/interfaces without a leading "#", leaving a bare line in the network configuration of a hypervisor running 22 guests. ifquery tolerated it, but a later reload need not have. Fixed, and the provisioner now validates the file after writing it. The lab tenant is destroyed; nothing is left running.
10 lines
149 B
Terraform
10 lines
149 B
Terraform
terraform {
|
|
required_version = ">= 1.6"
|
|
required_providers {
|
|
proxmox = {
|
|
source = "bpg/proxmox"
|
|
version = ">= 0.66"
|
|
}
|
|
}
|
|
}
|