feat(proxmox): cloud-init packages + runcmd via per-VM vendor snippet (E1)#145
Merged
Conversation
… (E1) Extend the VirtualMachine cloudInit spec with `packages` (installed on first boot, index refreshed first) and `runcmd` (first-boot commands), so a VM can install node prerequisites like open-iscsi for Longhorn. Proxmox has no native ci* option for arbitrary packages/runcmd, so these render into a per-VM cloud-init vendor snippet (client.RenderVendorData, via yaml.Marshal for safe escaping of arbitrary commands) uploaded to snippets storage and attached with `cicustom vendor=`. vendor-data is additive to Proxmox's generated user-data — unlike a `user=` snippet, which would replace ciuser/cipassword/sshkeys — so those are preserved. The no-packages/no-runcmd path keeps the shared static qemu-agent snippet byte-identical (no risk to the metal-validated QGA IP-discovery flow); the combined path folds the agent runcmd in so IP discovery still works. Both proxmox create paths (template clone, cloud-image) share one helper. Also documents the previously-missing `packageUpgrade` in the CUE schema. plugins/proxmox gains a yaml.v3 indirect require + go.sum (transitive via pkg/proxmox/client). Unblocks F1 (Longhorn). Tests: vendor-data render (ordering, omitempty, special-char round-trip), spec parse, handler wiring (per-VM upload + cicustom). Metal validation of actual package install is a homelab follow-up, like A1-A4.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
E1 — cloud-init
packages+runcmdExtends the Proxmox
VirtualMachinecloudInitspec so a VM can install host packages and run first-boot commands — the one true prerequisite for F1 (Longhorn), which needsopen-iscsion nodes.Design decision: per-VM vendor snippet
Proxmox has no native
ci*option for arbitrary packages/runcmd. So these render into a real#cloud-configsnippet:client.RenderVendorData(packages, runcmd)builds the config viayaml.Marshal(arbitrary commands escape safely — no hand-concatenation), always leadingruncmdwith the qemu-guest-agent enablement, then the user's commands.package_update: trueis emitted whenever packages are present.openctl-vendor-<vmid>.yaml) and attached viacicustom vendor=.vendor=notuser=: vendor-data is additive to Proxmox's generated user-data, sociuser/cipassword/sshkeysare preserved. Auser=snippet would replace them.Risk containment
The no-packages/no-runcmd path is byte-identical to before — it still uses the shared static qemu-agent snippet, so the metal-validated QGA IP-discovery flow is untouched. Only when
packages/runcmdare set does the code switch to the per-VM combined snippet (which folds the agent commands in, so IP discovery still works). Both create paths (template clone, cloud-image) now share oneapplyCloudInitVendorSnippethelper.Also
packageUpgradefield in the CUE schema.plugins/proxmoxgains ayaml.v3indirect require + a newgo.sum(transitive viapkg/proxmox/client).Tests
RenderVendorData: ordering (agent-first),omitemptyfor no-packages, special-char round-trip (colons/quotes/hashes in runcmd parse back intact).ParseVMSpec: packages/runcmd parsed, non-string entries skipped.cicustom=vendor=local:snippets/openctl-vendor-200.yamlconfig.Local CI: build,
go test ./...(+-raceon proxmox), gofmt, vet, staticcheck, golangci-lint (0 issues), modernize — root and the proxmox plugin module — all green.Metal validation (does
open-iscsiactually install on a real node) is a homelab follow-up, consistent with how A1–A4 shipped.