Provisioning

Central control plane for a Proxmox homelab cluster. Handles PXE booting bare metal, unattended Proxmox installation, cluster join, and host lifecycle management.

What it does

  1. Operator registers a host: MAC address, server type, and its static address (CIDR, outside the DHCP pool); optionally a corosync address
  2. Operator triggers "rebuild with Proxmox". Provisioning refuses up front unless the config is complete, the host has a static address, and the default image was prepared for unattended install
  3. Provisioning generates the rebuild's ephemeral SSH key and token, renders the host's answer file and checks it with proxmox-auto-install-assistant validate-answer; only then does the host move to pxe_ready
  4. Host PXE boots → dnsmasq responds → iPXE loads the Proxmox installer kernel and initrd; the overlay downloads the prepared ISO
  5. The installer POSTs its system information to /api/boot/answer; Provisioning finds the host by MAC and returns its answer file: static network pinned to the host's NIC, ZFS on the server type's boot disk, the ephemeral key for root
  6. Proxmox installs unattended → post-install webhook fires
  7. First boot fetches its script (gated by the rebuild token) and phones home with its address, hardware ID and SSH host key
  8. Provisioning SSHes in with the ephemeral key, pinned to that host key; authorizes the node's root key on the existing node for the join, removes the ephemeral key, runs pvecm add <existing> --use_ssh 1 --link0 <corosync address>, then revokes the temporary authorization. No passwords, no unverified host keys
  9. Rebuild token and ephemeral key forgotten; host registered in Infrastructure, the host registry → marked ready

Admin dashboard shows real-time progress via SSE.

Host States

registered → pxe_ready → pxe_booted → installing → installed → first_boot → joining → ready
                                                                                         ↓
                                                                                       failed

Deploy

Prerequisites

  • Docker + Docker Compose on the target host
  • Host must be on the same network as the bare-metal nodes (for PXE/DHCP)
  • Registry access to gitea.thewrightserver.net

Provisioning generates an ephemeral SSH key per rebuild for the new node. For the join it needs one standing key of its own, authorized for root on one existing cluster member (proxmox.ssh_key_path), and that member's pinned host key.

Setup

# Log in to the container registry
docker login gitea.thewrightserver.net

# Run the install script (creates /opt/provisioning with config templates)
curl -sf https://gitea.thewrightserver.net/josh/Provisioning/raw/branch/main/deploy/install.sh | bash

Or manually:

mkdir -p /opt/provisioning && cd /opt/provisioning
curl -sfO https://gitea.thewrightserver.net/josh/Provisioning/raw/branch/main/docker-compose.yml
curl -sf https://gitea.thewrightserver.net/josh/Provisioning/raw/branch/main/deploy/provisioning.example.yaml -o provisioning.yaml
curl -sf https://gitea.thewrightserver.net/josh/Provisioning/raw/branch/main/deploy/server-types.example.yaml -o server-types.yaml

Configure

Edit provisioning.yaml (see deploy/provisioning.example.yaml, which carries the TWS values):

Key Description
server.public_url LAN-reachable URL (e.g. http://192.168.1.40:8080); baked into prepared ISOs as the answer URL
pxe.interface NIC name on the host (e.g. eth0, enp2s0)
pxe.subnet LAN CIDR for proxy-DHCP
images.auto_install_assistant Path to proxmox-auto-install-assistant (apt install proxmox-auto-install-assistant from the Proxmox VE repository)
install.domain, .timezone, .mailto, .keyboard, .country [global] values of every answer file
network.gateway, network.dns Shared by every node's static network
proxmox.existing_node IP of the cluster member new nodes join through
proxmox.ssh_key_path Provisioning's private key; its public half must be in that node's /root/.ssh/authorized_keys
proxmox.existing_node_host_key That node's SSH host key (cat /etc/ssh/ssh_host_ed25519_key.pub), pinned for every connection
credentials.root_password_hash Generate with mkpasswd -m sha-512
infrastructure.base_url URL of Infrastructure, the host registry (physical hosts and their NICs; Catalyst is instances only). Empty skips it, for development
infrastructure.server_type_map Maps local type keys to Infrastructure IDs

At startup Provisioning logs which of these a rebuild still needs; POST /api/hosts/{id}/rebuild answers 422 with the list.

Run

docker compose up -d

Dashboard at http://<host>:8080.

Update

docker compose pull
docker compose up -d

API

Host Management

Method Path Description
GET /api/hosts List all hosts
GET /api/hosts/{id} Get host details
POST /api/hosts Register host (hostname, mac, server_type, address CIDR, optional corosync_address)
PATCH /api/hosts/{id}/network Set address and corosync_address (refused while a rebuild runs)
DELETE /api/hosts/{id} Remove host
POST /api/hosts/{id}/rebuild Start rebuild operation (422 lists unmet preconditions)

Boot Flow (called by PXE-booting hosts)

Method Path Description
GET /ipxe/{mac} iPXE boot script
POST /api/boot/answer Proxmox answer file (TOML); host found by a MAC in the installer's system info, else by ARP. /api/boot/auto-answer is kept as an alias
POST /api/hosts/{id}/installed Post-install webhook
GET /api/hosts/{id}/first-boot-script?token= First-boot shell script; needs the rebuild token
POST /api/hosts/{id}/phone-home First boot reports IP, hardware ID and SSH host key; needs the rebuild token

Dashboard

Method Path Description
GET / Host grid with live state tiles
GET /hosts/{id} Host detail + operation history
GET /events SSE stream

Development

Requires Go 1.26 and, for make lint/make check, golangci-lint v2.

# What CI runs: tidy, vet, lint, race-enabled tests
make check

# Tests only
make test

# Run locally (PXE disabled)
cp deploy/provisioning.example.yaml provisioning.yaml
cp deploy/server-types.example.yaml server-types.yaml
# Edit provisioning.yaml: set pxe.enabled=false, infrastructure.base_url=""
go run ./cmd/provisioning -config provisioning.yaml

# Build binary
make build

# Build Docker image locally
make docker

Architecture

cmd/provisioning/       Entry point, wiring, shutdown
internal/
  config/               YAML config + hot-reloaded server types (fsnotify)
  db/                   SQLite (WAL mode, embedded migrations)
  model/                Domain types (Host, Operation, Image, ServerType)
  store/                SQL stores (hosts, operations, locks, images)
  statemachine/         Table-driven host state machine
  events/               SSE fan-out hub
  pxe/                  dnsmasq supervisor, iPXE scripts, answer files, first-boot
  orchestrator/         Lifecycle driver (ephemeral keys, cluster join, infra registration)
  infra/                Infrastructure API client
  api/                  HTTP handlers (JSON API + HTML dashboard)
  httpserver/           chi router assembly
  web/                  Embedded static assets (CSS, JS)

CI/CD

Gitea Actions workflow (.gitea/workflows/build.yml):

  • On every pull request and push to main: go mod tidy must leave go.mod/go.sum unchanged, go vet, golangci-lint (config in .golangci.yml), and go test -race with a coverage summary
  • On push to main only: builds the Docker image and pushes it to gitea.thewrightserver.net/josh/provisioning:latest
S
Description
No description provided
Readme
371 KiB
0 Stars 1 Watchers 1 Forks
Languages
Go 91.7%
CSS 5%
JavaScript 2.3%
Shell 0.5%
Dockerfile 0.3%
Other 0.2%