Compare commits

..

1 Commits

Author SHA1 Message Date
unkinben bcbb855dd8 Add image-based provisioning (liveimg) + shared storage partial
ci/woodpecker/push/pre-commit Pipeline was successful
ci/woodpecker/push/validate Pipeline was successful
Adds a fast, reproducible install path that unpacks a prebuilt AlmaLinux 9 node
rootfs onto the disk instead of resolving packages, with per-host networking
still templated after the unpack. Storage reuses the OptiPlex model vars so
image and package installs lay disks out identically.

- kickstart/image.ks.tmpl: liveimg --url={{ .DistroVars.rootfs_tarball }};
  %post renders per-host NetworkManager keyfiles from NetBox interface data
  (the image is generic and liveimg clobbers /etc), sets hostname, the
  puppet-initial PUPPETCA_URL env, and the provisioned callback.
- kickstart/_storage.ks.tmpl: shared storage-block/storage-pre partials
  (storage_mode / vg_grow); almalinux9.ks.tmpl now uses them too (no behaviour
  change) so both installs share one storage layout.
- catalog/almalinux9-image.yaml (generic autopart) + optiplex-7080-image.yaml
  (auto-nvme + vg_grow) point liveimg at the artifactapi rootfs-images repo.
- .woodpecker/build-image.yaml: builds the rootfs via dnf --installroot,
  tars almalinux9-node-<ver>.tar.zst, uploads to the rootfs-images local repo
  on tag node-image-<ver>.

Validated with bootapi validate + shellcheck; no bootapi code change (DistroVars
+ existing interface data suffice).

Claude-Session: https://claude.ai/code/session_015ur3i7D2azsMAWTSVABApv
2026-07-29 21:44:14 +10:00
6 changed files with 99 additions and 46 deletions
+81
View File
@@ -0,0 +1,81 @@
when:
- event: tag
ref: refs/tags/node-image-*
# Builds the AlmaLinux 9 node rootfs with dnf --installroot, tars it as
# almalinux9-node-<ver>.tar.zst and PUTs it to the artifactapi rootfs-images
# local (generic) repo, where the almalinux9-image catalog entry's liveimg
# points. Tag as node-image-<ver> (e.g. node-image-20260729); the tarball
# version is that suffix. Baked here = everything the image %post assumes is
# already installed (kernel/grub/dracut, NetworkManager, openssh, chrony,
# kexec-tools, curl, puppet-agent, ...). Per-host config stays in image.ks.tmpl.
steps:
- name: build-rootfs
image: git.unkin.net/unkin/almalinux9-base:20260606
commands:
- dnf -y install tar zstd dnf-plugins-core
- VER="${CI_COMMIT_TAG#node-image-}"
- ROOT="$${CI_WORKSPACE}/rootfs"
- mkdir -p "$$ROOT"
# Base system + boot chain (BIOS + UEFI), storage, networking, node tools.
- |
dnf -y --installroot="$$ROOT" --releasever=9 --setopt=install_weak_deps=False install \
@core kernel \
grub2-pc grub2-efi-x64 shim-x64 grub2-tools grub2-tools-efi efibootmgr \
dracut dracut-config-generic \
lvm2 xfsprogs e2fsprogs dosfstools \
NetworkManager selinux-policy-targeted policycoreutils \
openssh-server chrony kexec-tools bind-utils vim-minimal tmux git curl \
glibc-langpack-en
# Puppet agent baked in; image.ks.tmpl %post only configures it.
- dnf -y --installroot="$$ROOT" install https://yum.puppet.com/puppet8-release-el-9.noarch.rpm
- dnf -y --installroot="$$ROOT" install puppet-agent
- dnf -y --installroot="$$ROOT" clean all
- rm -rf "$$ROOT"/var/cache/dnf/* "$$ROOT"/var/log/dnf* "$$ROOT"/etc/machine-id
# Reproducible, ownership/xattr/SELinux-preserving tarball.
- tar --numeric-owner --acls --xattrs --selinux -C "$$ROOT" -caf "almalinux9-node-$${VER}.tar.zst" .
- ls -lh "almalinux9-node-$${VER}.tar.zst"
backend_options:
kubernetes:
serviceAccountName: default
resources:
requests:
memory: 2Gi
cpu: 2
ephemeral-storage: 8Gi
limits:
memory: 4Gi
cpu: 4
ephemeral-storage: 16Gi
- name: upload
image: git.unkin.net/unkin/almalinux9-base:20260606
commands:
- VER="${CI_COMMIT_TAG#node-image-}"
- |
HOST="https://artifactapi.k8s.syd1.au.unkin.net"
REPO="rootfs-images"
FILE="almalinux9-node-$${VER}.tar.zst"
# Local generic repo: PUT stores the raw file; overwrites 409-reject, so
# skip if this version already exists (probe the GET path).
code=$$(curl -s -o /dev/null -w '%{http_code}' "$$HOST/api/v2/remotes/$$REPO/files/$$FILE" || true)
if [ "$$code" = "200" ]; then
echo "$$FILE already exists (HTTP $$code); skipping upload"
exit 0
fi
curl -f -X PUT "$$HOST/api/v2/remotes/$$REPO/files/$$FILE" \
-H "Content-Type: application/zstd" \
--data-binary @"$$FILE"
depends_on: [build-rootfs]
backend_options:
kubernetes:
serviceAccountName: default
resources:
requests:
memory: 512Mi
cpu: 500m
ephemeral-storage: 8Gi
limits:
memory: 1Gi
cpu: 1
ephemeral-storage: 16Gi
+11 -14
View File
@@ -29,11 +29,11 @@ YAML + template change here — **no bootapi code change**.
`almalinux/<ver>/BaseOS/<arch>/os/`. Generic / VM default (autopart on `sda`).
- **fedora** — artifactapi `fedora` remote, tree
`fedora/releases/<ver>/Everything/<arch>/os/`.
- **optiplex-3050 / optiplex-3060 / optiplex-3070 / optiplex-7080** — AlmaLinux 9
on the Dell OptiPlex fleet. Same install tree and `almalinux9` kickstart
template, but each passes a `storage_mode` (and, for the 7080, `vg_grow`) var
so the one template lays disks out per model. Ported from the Cobbler profiles
`almalinux9-dell_3050 / _3060 / _3070 / _7080`. See "Per-model variants" below.
- **optiplex-3050 / optiplex-3060 / optiplex-7080** — AlmaLinux 9 on the Dell
OptiPlex fleet. Same install tree and `almalinux9` kickstart template, but
each passes a `storage_mode` (and, for the 7080, `vg_grow`) var so the one
template lays disks out per model. Ported from the Cobbler profiles
`almalinux9-dell_3050 / _3060 / _7080`. See "Per-model variants" below.
## Per-model variants (Dell OptiPlex)
@@ -45,7 +45,6 @@ model-specific `storage_mode` var:
|-------|----------------|----------------|----------|--------|
| `optiplex-3050` | `fixed-nvme` | static `nvme0n1` | legacy BIOS/MBR | fixed ~31G |
| `optiplex-3060` | `auto-nvme` | `%pre` picks first NVMe <512G | UEFI-aware (EFI part if booted UEFI) | fixed ~31G |
| `optiplex-3070` | `auto-nvme` | `%pre` picks first NVMe <512G | UEFI-aware | fixed ~31G |
| `optiplex-7080` | `auto-nvme` + `vg_grow: "true"` | `%pre` picks first NVMe <512G | UEFI-aware | grows to fill disk |
The kickstart (`kickstart/almalinux9.ks.tmpl`) reads `.DistroVars.storage_mode`
@@ -55,7 +54,7 @@ autopart-on-`sda` path.
**Model selection (NetBox-driven, no code change):** the entry `name` is the
OptiPlex **device_type slug**. Set the device's `provision_template` custom
field to that slug (`optiplex-3050` / `-3060` / `-3070` / `-7080`) and bootapi's catalog
field to that slug (`optiplex-3050` / `-3060` / `-7080`) and bootapi's catalog
`Select` picks the matching entry (override precedence beats platform/family).
The `match.platforms` slug on each entry is the device_type slug too — not a
real NetBox platform slug — so these entries are *only* reachable via the
@@ -87,13 +86,11 @@ vars:
- **Networking is templated per-host in `%post`** (NetworkManager keyfiles from
the same NetBox interface data), because the generic image has no per-host
identity and the `liveimg` unpack overwrites `/etc`.
- The tarball is built by the separate
[bootapi-images](https://git.unkin.net/unkin/bootapi-images) repo (a `v*` tag
builds and uploads `almalinux9-node-<ver>.tar.zst` to the artifactapi
`rootfs-images` local repo). Baked into the image = everything the `%post`
assumes present (kernel/grub/dracut, NetworkManager, openssh, chrony,
kexec-tools, curl, puppet-agent). Bump an image = new bootapi-images release +
a one-line `rootfs_tarball` edit here.
- The tarball is built by `.woodpecker/build-image.yaml` (tag `node-image-<ver>`)
and uploaded to the artifactapi `rootfs-images` local repo. Baked into the
image = everything the `%post` assumes present (kernel/grub/dracut,
NetworkManager, openssh, chrony, kexec-tools, curl, puppet-agent). Bump an
image = new tag + one-line `rootfs_tarball` edit here.
## Adding another distro (the intended path)
+4 -4
View File
@@ -16,7 +16,7 @@ kernel_args:
- inst.text
- net.ifnames=0
vars:
# Prebuilt node rootfs on the artifactapi rootfs-images local repo, built and
# published by the bootapi-images repo (v* tag). Immutable, semver-versioned;
# bump this one line to roll the fleet forward (overwrites are 409-rejected).
rootfs_tarball: "https://artifactapi.k8s.syd1.au.unkin.net/api/v2/remotes/rootfs-images/files/almalinux9-node-1.0.0.tar.zst"
# Prebuilt node rootfs on the artifactapi rootfs-images local repo, built by
# .woodpecker/build-image.yaml. Immutable, date-versioned; bump this one line
# to roll the fleet forward (overwrites are 409-rejected).
rootfs_tarball: "https://artifactapi.k8s.syd1.au.unkin.net/api/v2/remotes/rootfs-images/files/almalinux9-node-20260729.tar.zst"
-23
View File
@@ -1,23 +0,0 @@
# Distro catalog entry: AlmaLinux 9 on the Dell OptiPlex 3070.
#
# Ported for the six prodnxsr0014-0019 bare-metal hosts registered on the legacy
# Cobbler server under profile almalinux9-dell_3070. Mirrors optiplex-3060: a
# %pre script auto-selects the internal NVMe (first under 512G), is UEFI-aware,
# sets bootloader --boot-drive, and uses a fixed ~31G LVM (no grow). The Cobbler
# almalinux9_dell3070 kickstart template currently fails to render on cobbler,
# so the closest working per-model profile (3060, same UEFI/auto-NVMe layout,
# fixed LVM) was used as the source of truth. Select it by setting the device's
# `provision_template` custom field to "optiplex-3070" (the device_type slug).
name: optiplex-3070
match:
platforms: [optiplex-3070]
kickstart: almalinux9
version_default: "9"
kernel_url: "{{.ArtifactBase}}/almalinux/{{.Version}}/BaseOS/{{.Arch}}/os/images/pxeboot/vmlinuz"
initrd_url: "{{.ArtifactBase}}/almalinux/{{.Version}}/BaseOS/{{.Arch}}/os/images/pxeboot/initrd.img"
kernel_args:
- inst.text
- net.ifnames=0
vars:
mirror: "{{.ArtifactBase}}/almalinux/{{.Version}}"
storage_mode: auto-nvme
+1 -1
View File
@@ -16,6 +16,6 @@ kernel_args:
- inst.text
- net.ifnames=0
vars:
rootfs_tarball: "https://artifactapi.k8s.syd1.au.unkin.net/api/v2/remotes/rootfs-images/files/almalinux9-node-1.0.0.tar.zst"
rootfs_tarball: "https://artifactapi.k8s.syd1.au.unkin.net/api/v2/remotes/rootfs-images/files/almalinux9-node-20260729.tar.zst"
storage_mode: auto-nvme
vg_grow: "true"
+2 -4
View File
@@ -6,14 +6,12 @@ it. Mirrors how Cobbler generated a per-MAC gPXE script carrying inst.ks=.
KernelURL/InitrdURL/RepoURL come from the selected catalog entry (artifactapi
remote); KernelArgs are the catalog's extra args. KickstartURL uses
BOOTAPI_BASE_URL (http://). inst.ks.sendmac makes anaconda send its interface
MACs as X-RHN-Provisioning-MAC-N headers when fetching the kickstart (Cobbler
parity; lets /ks resolve a host by MAC as well as by name).
BOOTAPI_BASE_URL (http://).
*/ -}}
#!ipxe
echo bootapi: provisioning {{ .FQDN }} ({{ .Platform }})
{{ if and .KernelURL .InitrdURL -}}
kernel {{ .KernelURL }} initrd=initrd.img{{ if .RepoURL }} inst.repo={{ .RepoURL }}{{ end }} inst.ks.sendmac inst.ks={{ .KickstartURL }} ip=dhcp{{ range .KernelArgs }} {{ . }}{{ end }}
kernel {{ .KernelURL }} initrd=initrd.img{{ if .RepoURL }} inst.repo={{ .RepoURL }}{{ end }} inst.ks={{ .KickstartURL }} ip=dhcp{{ range .KernelArgs }} {{ . }}{{ end }}
initrd {{ .InitrdURL }}
boot
{{- else -}}