Skip to content

Packer: native proxmox-clone builder + selectable qemu output (#1) - #4

Open
michielvha wants to merge 2 commits into
mainfrom
feat/0001-packer-proxmox-native
Open

Packer: native proxmox-clone builder + selectable qemu output (#1)#4
michielvha wants to merge 2 commits into
mainfrom
feat/0001-packer-proxmox-native

Conversation

@michielvha

Copy link
Copy Markdown
Contributor

Implements spec 0001 (docs/specs/0001-packer-proxmox-native-output.md). Closes #1.

What changed

One Ubuntu template, two builders sharing a single build block, selected at invocation:

  • proxmox-clone.ubuntu — native Proxmox template. Clones a cloud-image base template, customizes it, attaches an empty cloud-init drive (cloud_init + cloud_init_storage_pool), authenticates with an API token, and ends flagged as a template. No per-build qm importdisk.
  • qemu.ubuntu — portable qcow2, now arch-parameterized (amd64 default; arm64 for a fast HVF build on Apple Silicon).

Supporting changes:

  • scripts/create-base-template.sh — Stage-0 one-time base-template bootstrap (cloud image + qemu-guest-agent → template).
  • install.sh trimmed to generic (just waits for cloud-init); tooling deferred to Spec 0003: Move provisioning into PDS (select and apply) #3.
  • cleanup.sh seals the image: cloud-init clean, machine-id + dbus reset, remove SSH host keys and the build authorized_keys.
  • cloud-init seed stripped of identity (hostname vars) and amd64-only grub packages so it stays generic and arch-portable.
  • Secrets: token via PKR_VAR_proxmox_api_token or an untracked *.auto.pkrvars.hcl (.example added); .gitignore covers outputs and real vars files.
  • Removed orphaned scripts/.p10k.zsh + scripts/zshrc (zsh config returns via PDS in Spec 0003: Move provisioning into PDS (select and apply) #3).

Testing

  • packer fmt -check — clean.
  • packer validate — green for both builders (-only=qemu.ubuntu and the full template).
  • packer build -only='qemu.ubuntu'completed (5m29s, amd64 under TCG). Produced a sealed 922 MB qcow2; the build log confirms every generic-image step ran (machine-id truncate + dbus symlink, rm authorized_keys, rm ssh_host_*, cloud-init clean, graceful halt, qcow2 convert).
  • proxmox-clone verified statically (packer validate); a live PVE build is intentionally deferred to the phase-2 self-hosted runner in spec 0002 (no token shared into the dev session).

Scope notes / follow-ups

Open (need your homelab values before a real Proxmox build)

Storage pool, bridge, node, and vmid ranges go in the untracked proxmox.auto.pkrvars.hcl; base template created once via create-base-template.sh.

Convert the Ubuntu template to the native hashicorp/proxmox proxmox-clone
builder alongside the existing qemu builder, selectable at invocation with
-only. Both share one build block and produce a generic, unidentified image.

- required_plugins: proxmox >= 1.2.2 + qemu ~> 1
- source proxmox-clone.ubuntu: clones a cloud-init base template, attaches an
  empty cloud-init drive (cloud_init + cloud_init_storage_pool), API-token auth,
  ends as a Proxmox template. No per-build qm importdisk.
- source qemu.ubuntu: portable qcow2, now arch-parameterized (amd64 default;
  arm64 for a fast HVF build on Apple Silicon).
- scripts/create-base-template.sh: Stage-0 one-time base-template bootstrap.
- install.sh trimmed to generic (waits for cloud-init); tooling deferred to #3.
- cleanup.sh seals the image: cloud-init clean, machine-id + dbus reset, remove
  SSH host keys and build authorized_keys.
- cloud-init seed stripped of identity (hostname vars) and amd64-only grub pkgs
  so it stays generic and arch-portable.
- secrets: token via PKR_VAR/untracked *.auto.pkrvars.hcl (+ .example); gitignore
  outputs and real vars files.
- remove orphaned scripts/.p10k.zsh + scripts/zshrc (zsh config returns via PDS in #3).

Tested locally: packer fmt clean, packer validate green (both builders), and a
full 'packer build -only=qemu.ubuntu' produced a sealed qcow2 (cleanup steps
verified in the build log). proxmox-clone verified statically; live PVE build is
phase-2 per spec 0002.

Refs #1
The baseline tooling that lives in Ubuntu's default apt repos belongs in the
cloud-init packages list (native apt integration), not deferred to PDS. Restore
git, net-tools, nmap, nfs-common, build-essential, zsh, btop alongside
qemu-guest-agent/curl/file. Only genuinely non-apt cases stay for PDS (#3): gh
(needs the cli.github.com repo) and neofetch (deprecated; goes with the MOTD).
grub-efi-amd64/shim-signed stay dropped (amd64-only, not needed for a cloud image).

Re-ran packer build -only=qemu.ubuntu: green (5m53s), all packages install
cleanly, image sealed as before.

Refs #1
@michielvha

Copy link
Copy Markdown
Contributor Author

Good catch on the package trimming, applied. Corrected the philosophy: apt-native packages stay in cloud-init (git, net-tools, nmap, nfs-common, build-essential, zsh, btop, curl, file, qemu-guest-agent), and only genuinely non-apt things defer to PDS (#3): gh (needs the cli.github.com repo) and neofetch (deprecated, rides along with the MOTD). grub-efi-amd64/shim-signed stay dropped (amd64-only, unnecessary for a cloud image).

Re-ran packer build -only=qemu.ubuntu: green in 5m53s, all packages install cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spec 0001: Packer Proxmox-native builder with selectable output formats

1 participant