Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ docstring gives: it is a record, not a claim about now.

## 2026-11-18

- **`eden` no longer asks for an address while it boots, and template `901`
stops making guests that do.** `eden` was off when "Every 26.04 lab guest
asked the lab's DHCP server for an address while it booted", below, was
written. Read when it next started, its initramfs had leased `.106` from
the pool on both boots of 2026-11-16 and `.101` at 05:10 UTC today. `eden`
is not an ISO install but a clone of Packer template `901`, so the cause is
in the template, and every later clone would have done the same.
- **The template:** `packer/ubuntu/no-initramfs-network.sh` now runs after
the upgrade. It writes the drop-in the hand-installed guests carry,
rebuilds every initramfs, and fails the build if one still has
networking. `901` has not been rebuilt with it yet.
- **The smoke test:** `scripts/packer-smoke.sh` now fails a Linux clone whose
journal shows DHCP before switch-root. Run against `eden` before the fix,
its check read 2.
- **`eden` itself:** `build-the-bloodhound-guest.md` §2 carries the step for
a clone of an older `901`. Applied at 05:15 UTC, the reboot at 05:16
showed no DHCP or networkd before switch-root, and `eth0` held only `.41`.
`/srv/bloodhound-data` was mounted, all five BloodHound containers came
back, and the rollback copy is deleted.
- **`alexander`, `odin` and `phoenix` no longer ask for an address while
they boot.** This completes "Every 26.04 lab guest asked the lab's DHCP
server for an address while it booted", below, which said the runbooks'
Expand Down
44 changes: 44 additions & 0 deletions docs/runbooks/build-the-bloodhound-guest.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,50 @@ sudo stat -c '%a %u %n' /srv/bloodhound-data/postgres/18/docker # 700 999
`qm guest cmd 141 get-fsinfo` on `Saruman` should list `/` and
`/srv/bloodhound-data`.

### No network in the initramfs

Ubuntu 26.04's initramfs is dracut's. It carries systemd-networkd and a
catch-all, `zzzz-dracut-default.network`, that runs DHCP on every interface,
so the NIC asks the lab's DHCP server for an address before the static `.41`
applies. `eden` leased `.106` from the pool on both of its boots on
2026-11-16, and `.101` on 2026-11-18. Template `901` leaves networking out of
the initramfs since `packer/ubuntu/no-initramfs-network.sh`, so a clone of a
template built after that needs only the check below. A clone of an older
`901`, `eden` as built, needs the drop-in the hand-installed guests carry
([`build-the-lab-guest.md`](build-the-lab-guest.md) §2):

```bash
sudo tee /etc/dracut.conf.d/10-homelab-no-network.conf >/dev/null <<'CONF'
# eden: no networking in the initramfs (build-the-bloodhound-guest.md §2).
# The root disk is local. With systemd-networkd in the image, its catch-all
# DHCPs the NIC before the static address applies.
# Same line as dracut's own dracut.conf.d/no-network profile.
omit_dracutmodules+=" net-lib systemd-networkd "
CONF
ls /var/run/reboot-required 2>/dev/null && echo 'reboot first'
k="$(uname -r)"
sudo cp -p "/boot/initrd.img-$k" "/boot/initrd.img-$k.pre-no-network"
sudo update-initramfs -u -k "$k"
sudo lsinitrd -m "/boot/initrd.img-$k" | grep -E 'net-lib|systemd-networkd' # nothing
```

If `reboot first` prints, reboot, then run the last four lines. The
`dracut[E]` line for `dyn-netconf` is the omit working, as `alexander`'s §2
says. If the new image does not boot, open VM 141's console in the Proxmox web
UI, hold Esc for GRUB's menu, press `e`, add `.pre-no-network` to the end of
the `initrd` line's file name, and boot with Ctrl-X.

Either way, reboot and check that nothing before switch-root asked for an
address. The initramfs calls the NIC `ens18`; the running system calls it
`eth0`:

```bash
sudo journalctl -b -o short-iso | awk '/Switching root/{exit} {print}' | grep -cE 'DHCPv4|zzzz-dracut-default' # 0
ip -4 -o addr show eth0 | awk '{print $4}' # 10.0.30.41/24
```

Then delete the copy, if you made one.

## 3. Docker, the repository, and its own key

Install Docker, `age`, `git` and `make` as `alexander`'s §3 describes, and add
Expand Down
10 changes: 8 additions & 2 deletions docs/runbooks/build-the-lab-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,11 @@ What each one does, so a stall can be placed:
`autoinstall` off the kernel line, and fails the build if any of that is
left. Packer then upgrades, turns off X11 forwarding, takes `lxd` out of
cloud-init's default user groups, and wipes cloud-init's state, machine-id
and host keys. It then deletes the `packer` user.
and host keys. `packer/ubuntu/no-initramfs-network.sh` then rebuilds every
initramfs without networking, so a clone does not ask the lab's DHCP server
for an address while it boots, and fails the build if one still has it. It
prints a `dracut[E]` line for `dyn-netconf`, which is the omit working.
It then deletes the `packer` user.
- **Fedora** picks "Install Fedora" from the GRUB menu, whose default is
the media check. Anaconda finds `ks.cfg` on the `OEMDRV` disc by itself,
installs Server unattended in text mode, and reboots. The rest is
Expand Down Expand Up @@ -669,7 +673,9 @@ scripts/packer-smoke.sh 910
Each run makes a full clone at VMID 999. For Linux, it gives the clone user
`smoke`, `phoenix`'s key and DHCP through cloud-init, boots it, and waits for
the agent to report an address. It then checks the hostname and SSHes in.
Finally it destroys the clone.
Where the clone booted through a systemd initramfs, it checks the journal
shows no DHCP before switch-root; a clone of a `901` built before
`no-initramfs-network.sh` fails there. Finally it destroys the clone.

A Windows clone runs specialize and OOBE first. Its guest agent is disabled in
the template, and `SetupComplete.cmd` starts it as its last step, so the
Expand Down
7 changes: 7 additions & 0 deletions packer/ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ build {
]
}

# After the upgrade, so every kernel a clone can boot has its image rebuilt
# without networking. The script fails the build if one still carries it.
provisioner "shell" {
execute_command = "sudo -E sh -eu '{{ .Path }}'"
script = "${abspath(path.root)}/ubuntu/no-initramfs-network.sh"
}

# Last: remove the build user. -f because this session is that user's, and
# skip_clean because the script cannot delete itself from a home directory
# that no longer exists. The builder then shuts the guest down through the
Expand Down
55 changes: 55 additions & 0 deletions packer/ubuntu/no-initramfs-network.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh
# Leaves networking out of every initramfs in the template, as root over
# Packer's SSH session (packer/ubuntu.pkr.hcl). Runs after the upgrade, so the
# kernel a clone boots is one of the images rebuilt here.
#
# Ubuntu 26.04's initramfs is dracut's, and it carries systemd-networkd with a
# catch-all, zzzz-dracut-default.network, that runs DHCP on every interface.
# Every clone of 901 therefore took a lease from the lab pool while it booted,
# before cloud-init's static address applied: eden leased .106 and .101 on its
# boots of 2026-11-16 and 2026-11-18 (docs/changelog.md). The root disk is
# local, so the initramfs needs no network at all. This is the drop-in the
# hand-installed guests carry (build-the-sensor-guest.md §3).
#
# update-initramfs prints a dracut[E] line for dyn-netconf, from
# cloud-initramfs-dyn-netconf, which depends on systemd-networkd. That is the
# omit working; the lsinitrd check below is what decides.
set -eu

cat > /etc/dracut.conf.d/10-homelab-no-network.conf <<'CONF'
# No networking in the initramfs (packer/ubuntu/no-initramfs-network.sh).
# The root disk is local. With systemd-networkd in the image, its catch-all
# DHCPs every interface before cloud-init's static address applies.
# Same line as dracut's own dracut.conf.d/no-network profile.
omit_dracutmodules+=" net-lib systemd-networkd "
CONF
chmod 644 /etc/dracut.conf.d/10-homelab-no-network.conf

built=0
for v in /boot/vmlinuz-*; do
[ -e "$v" ] || continue
k="${v#/boot/vmlinuz-}"
update-initramfs -u -k "$k"
built=$((built + 1))
done
if [ "$built" -eq 0 ]; then
echo "no-initramfs-network.sh: no kernel found under /boot" >&2
exit 1
fi

# Fail the build rather than ship a template whose clones still DHCP at boot.
# The module list is read first, on its own: in `lsinitrd | grep` inside an
# `if`, the status is grep's and `set -e` does not apply, so an lsinitrd that
# failed would read as an image with no networking.
for img in /boot/initrd.img-*; do
[ -e "$img" ] || continue
if ! mods="$(lsinitrd -m "$img")" || [ -z "$mods" ]; then
echo "no-initramfs-network.sh: lsinitrd could not list the modules in $img" >&2
exit 1
fi
if printf '%s\n' "$mods" | grep -qE 'net-lib|systemd-networkd'; then
echo "no-initramfs-network.sh: $img still carries networking" >&2
exit 1
fi
done
echo "no-initramfs-network.sh: $built initramfs image(s) rebuilt without networking"
22 changes: 22 additions & 0 deletions scripts/packer-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# Linux the clone takes its name, user and key from the Proxmox cloud-init
# drive: the agent reports an address, get-host-name returns the name
# given here, and phoenix's key opens an SSH session that prints it.
# Where the clone booted through a systemd initramfs, its journal
# shows no DHCP before switch-root.
# Windows the generalised image finishes OOBE unattended and the guest agent
# comes up with an address. The agent is disabled in the template
# and started by SetupComplete.cmd as its last act, so an address
Expand Down Expand Up @@ -203,6 +205,26 @@ if [[ "${ostype}" == l26 ]]; then
got="$(ssh_hostname smoke)" || die "smoke@${addr} admitted no SSH login in three minutes"
[[ "${got}" == "${NAME}" ]] || die "ssh smoke@${addr} printed ${got}, expected ${NAME}"
ok "phoenix's key opens smoke@${addr}"
# A clone must not ask for an address before switch-root. Ubuntu's dracut
# initramfs did, on every clone of 901, until no-initramfs-network.sh: eden
# leased from the lab pool at each boot (packer/ubuntu/no-initramfs-network.sh).
# Only where the boot went through a systemd initramfs, whose journal marks
# the switch; a template without one has nothing here to check.
early="$(ssh -i "${SSH_KEY}" -o BatchMode=yes -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null -o LogLevel=ERROR "smoke@${addr}" \
'command -v journalctl >/dev/null || { echo none; exit 0; }
j="$(sudo -n journalctl -b -o cat 2>/dev/null)" || { echo unreadable; exit 0; }
printf "%s\n" "$j" | grep -q "Switching root" || { echo none; exit 0; }
printf "%s\n" "$j" | awk "/Switching root/{exit} {print}" | grep -cE "DHCPv4 address|zzzz-dracut-default" || true' \
2>/dev/null | tr -d '\r')"
case "${early}" in
0) ok "no DHCP before switch-root" ;;
none) ok "no systemd initramfs on this family, so no early DHCP to check" ;;
# Skipped, not passed: a family whose cloud-init user has no passwordless
# sudo cannot be read here. 901's can (eden, a clone, has it).
unreadable) printf '\033[0;33m SKIP\033[0m %s\n' "smoke@${addr} cannot read the journal with sudo -n: early DHCP not checked" ;;
*) die "the clone asked for an address before switch-root (${early:-no answer}): the initramfs still carries networking" ;;
esac
else
ok "hostname ${host} (sysprep's random name; the real one is ansible/'s)"
# The way ansible/ reaches every guest (ADR-0077): sshd, started by
Expand Down
Loading