Skip to content

feat(packer): build 901 without networking in its initramfs - #1569

Merged
Gerrrt merged 4 commits into
mainfrom
feat/packer-ubuntu-no-initramfs-network
Nov 18, 2026
Merged

Gerrrt merged 4 commits into
mainfrom
feat/packer-ubuntu-no-initramfs-network

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 18, 2026

Copy link
Copy Markdown
Owner

What changed

Template 901's build now leaves networking out of every initramfs, so its clones stop asking the lab's DHCP server for an address while they boot. eden, a clone of the old 901, has the fix applied by hand.

  • packer/ubuntu/no-initramfs-network.sh: a new provisioner that runs after the upgrade. It writes the dracut drop-in the hand-installed guests carry (omit_dracutmodules+=" net-lib systemd-networkd "), rebuilds every kernel's initramfs, and fails the build if lsinitrd -m still shows net-lib or systemd-networkd.
  • scripts/packer-smoke.sh: a Linux clone fails if its journal shows DHCP before switch-root. A family with no systemd initramfs passes as having nothing to check. One whose smoke user can't read the journal with sudo -n is printed as SKIP, not PASS.
  • docs/runbooks/build-the-bloodhound-guest.md §2: the step for a clone of an older 901. The proof reads eth0, which is what the running system calls the NIC the initramfs calls ens18.
  • docs/runbooks/build-the-lab-templates.md: the Ubuntu build description and §6's smoke test now mention both.
  • docs/changelog.md: a 2026-11-18 entry.

Why

eden was the one 26.04 guest not read for the lab-pool question, because it was off. Its journal shows the initramfs leasing .106 on both boots of 2026-11-16 and .101 at 05:10 UTC today. It's a clone of 901, not an ISO install, so the cause is in the template.

Blast radius

  • The template: the next 901 build. A wrong rebuild fails the build itself, and the smoke test catches a clone that still DHCPs.

  • eden: already applied, proved and running. If a later eden initramfs fails to boot, the runbook's GRUB fallback applies.

  • Other templates: the smoke change touches every Linux family. Where the clone has no systemd initramfs it passes as nothing to check; where the journal can't be read it is printed as SKIP.

  • No change to network segmentation or firewall rules

  • No new port published to a VLAN that could not already reach the service

  • No credential added outside secrets/*.sops.yaml

Verification

  • eden, applied by this session (passwordless sudo):

    • The rebuild found no network modules. dracut printed the expected dyn-netconf line.
    • After the 05:16 reboot: journal check 0, no networkd before switch-root, and eth0 held only 10.0.30.41/24.
    • /srv/bloodhound-data mounted, all five BloodHound containers back.
    • The rollback copy is deleted.
  • The new smoke check: its remote command, run against eden before the fix, printed 2, so the check can fail.

  • Not run:

    • The Packer build itself, so 901 is not rebuilt yet; that's build-the-lab-templates.md §8.
    • packer validate, packer fmt and zizmor: there's no local packer or Docker daemon. CI's lint runs them.
  • Local checks:

    • shellcheck passed on both scripts.
    • python3 scripts/check_docs.py → docs OK — 164 Prometheus + 21 Loki rules, 8 dashboards, 156 panels, 14 assertions.
    • ansible-lint fails in its local runner, as on main; no Ansible touched.
  • make validate passes (CI)

  • Deployed to the lab and confirmed working (eden yes; template 901 not rebuilt yet)

  • Docs updated (docs/, service README, or docs/roadmap.md)

🤖 Generated with Claude Code

Every clone of template 901 asked the lab's DHCP server for an address
from its dracut initramfs before its static address applied; eden leased
from the pool at each boot. The Ubuntu build now omits net-lib and
systemd-networkd from every initramfs and fails if one survives, the
smoke test fails a clone that DHCPs before switch-root, and eden's
runbook carries the step for clones of an older 901.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 05:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-initramfs-network

# Conflicts:
#	docs/changelog.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The initramfs check can silently accept an lsinitrd failure, allowing the build to report success without verifying that networking is absent.

1 open issue
What changed in this PR

This PR updates Ubuntu template 901 to prevent clones from requesting DHCP leases during early boot, before their configured networking takes effect. The template still needs rebuilding; eden has received the fix manually.

Changes:

  • Add a post-upgrade provisioner that removes initramfs networking, rebuilds images, and checks their modules.
  • Extend Linux smoke checks to detect DHCP before switch-root and report unreadable journals as skipped.
  • Document remediation for older clones and record the changes.
File Description
scripts/​packer-smoke.sh Checks Linux boot journals for early DHCP.
packer/​ubuntu/​no-initramfs-network.sh Disables initramfs networking and rebuilds and inspects images.
packer/​ubuntu.pkr.hcl Runs the new provisioner after upgrading Ubuntu.
docs/​runbooks/​build-the-lab-templates.md Describes the provisioner and expanded smoke checks.
docs/​runbooks/​build-the-bloodhound-guest.md Adds older-clone remediation, verification, and rollback steps.
docs/​changelog.md Records the template change and manual fix on eden.

Review effort: Balanced

Comment thread packer/ubuntu/no-initramfs-network.sh Resolved
In `if lsinitrd | grep -q`, the status is grep's and set -e does not
apply, so a failed lsinitrd read as an image without networking. Read
the module list first and fail if lsinitrd errors or lists nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gerrrt
Gerrrt enabled auto-merge (squash) November 18, 2026 05:24
@Gerrrt
Gerrrt merged commit 1e2be5c into main Nov 18, 2026
9 checks passed
@Gerrrt
Gerrrt deleted the feat/packer-ubuntu-no-initramfs-network branch November 18, 2026 05:36
Gerrrt added a commit that referenced this pull request Nov 18, 2026
Under set -e a failed x="$(ssh … 2>/dev/null)" ended the script with
nothing printed. The packer-user, early-DHCP and Panther checks now go
through ssh_run, which prints ssh's stderr and the exit status before
it dies.

Refs #1569

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gerrrt added a commit that referenced this pull request Nov 18, 2026
…ker user (#1571)

* docs(lab): record template 901 rebuilt; smoke-test for a leftover packer user

901 was rebuilt with no-initramfs-network.sh and packer-smoke.sh 901
passed, no DHCP before switch-root included. The rebuild's userdel
printed a busy warning that -f goes past, but `|| true` would hide a
failed delete, so the smoke test now fails a Linux clone that still has
a packer user.

Refs #1569

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(smoke): say why when an SSH check fails, not stop silently

Under set -e a failed x="$(ssh … 2>/dev/null)" ended the script with
nothing printed. The packer-user, early-DHCP and Panther checks now go
through ssh_run, which prints ssh's stderr and the exit status before
it dies.

Refs #1569

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants