Skip to content

fix(packer): Kali clones no longer come up without cloud-init - #1157

Closed
Gerrrt wants to merge 4 commits into
mainfrom
gerrrt/kali-cloud-init-first-boot-1127
Closed

Gerrrt wants to merge 4 commits into
mainfrom
gerrrt/kali-cloud-init-first-boot-1127

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Refs #1127.

What went wrong

On a clone's first boot, cloud-init's generator could be cut off before it enabled cloud-init.target. The guest then came up with no user, no SSH key, and the template's hostname. This happened on 2 of 7 first boots of template 910: garuda, and one of four disposable reproduction clones. On garuda's first boot, sslh's generator (sslh is pulled in by kali-linux-headless) aborted beside it, with no /etc/sslh. On its second boot it did not.

The fix

In packer/kali.pkr.hcl's shared provisioner, so both 910 and 902 get it:

  • Link cloud-init.target into multi-user.target. cloud-init no longer depends on its generator finishing. As a result ds-identify can no longer switch cloud-init off. Nothing here needs that: every clone gets a NoCloud drive.
  • Mask sslh's generator with a /dev/null link in /etc/systemd/system-generators. The package stays installed, so the Kali metapackages keep their dependency and nothing is autoremoved.

Garuda's runbook §4 now says a 910 built after this should not need the reboot workaround. The changelog has the counts.

Proof

  • Rebuild: template 910 was rebuilt with -force from this branch, in 26m31s. packer validate and fmt -check pass.
  • Clones: 12 disposable clones (VMID 997) of the rebuilt template were each booted the way tofu boots a guest. All 12 ran cloud-init: their own hostname, cloud-init status: done, and the generator completed. Before the fix, cloud-init failed on 2 of 7 first boots.
  • sslh: on the last 4, sslh's generator no longer aborts. I checked one clone by hand: the mask link is in place and the boot journal has no abort.
  • A correction: the first version of the reproduction check counted an sslh abort on every boot. It was matching its own command line, which qemu-ga writes to the journal. So the baseline's sslh figures are void. Its cloud-init figures stand, because those come from the hostname and cloud-init status.

#1127 is closed by hand with this evidence, since the rebuilt template is already live on Saruman.

🤖 Generated with Claude Code

Gerrrt and others added 2 commits October 10, 2026 09:11
On a clone's first boot cloud-init's generator could be cut off, leaving no
user, no key and the template's hostname: 2 of 7 first boots of template
910 on 2026-10-10 (garuda, and a reproduction run). sslh's generator, from
kali-linux-headless, aborted beside it on every first boot inspected.

The Kali build now masks sslh's generator (/dev/null in
/etc/systemd/system-generators, package kept) and links cloud-init.target
into multi-user.target, so cloud-init no longer depends on its generator.
Both template sources share the build, so 902 gets it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Correct the template comment's evidence: the first check counted its own
command in the journal, so only garuda's directly inspected first boot
shows sslh's generator aborting. Garuda's runbook §4 now says a 910 built
after the fix should not need the reboot. Changelog entry with the counts.

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

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.

🟢 Approval recommended

The operational fix is validated; only a minor overstatement in its explanatory comment remains.

1 open finding
What changed in this PR

Makes Kali templates reliably run cloud-init on clone first boot.

Changes:

  • Statically enables cloud-init.target and masks the sslh generator.
  • Updates the analyst runbook and records validation results.
  • One non-blocking documentation accuracy issue was identified.
File Description
packer/​kali.pkr.hcl Hardens first-boot cloud-init startup.
docs/​runbooks/​build-the-analyst-workstation.md Updates recovery guidance.
docs/​changelog.md Records the fault, fix, and proof.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packer/kali.pkr.hcl Resolved
Gerrrt and others added 2 commits October 10, 2026 14:05
The template comment said either change alone closes #1127; the cause is
not proved, and the 12-of-12 result tested both together, so it now says
that. Also rewords a runbook line that began with '#1127', which
markdownlint read as a heading (MD018), failing Lint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The static cloud-init.target link makes cloud-init start whatever cuts its
generator off; masking sslh's generator only helps if its abort is the
cause, and is kept because nothing uses sslh.

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

Gerrrt commented Oct 10, 2026

Copy link
Copy Markdown
Owner Author

Replaced by #1160. The tree is the same; it lands as one commit with a clean message. Commit a2f5b84 here said "closes" before the issue number mid-sentence, which fails the close-keyword gate. Removing it from this branch's history would have needed a force-push.

@Gerrrt Gerrrt closed this Oct 10, 2026
auto-merge was automatically disabled October 10, 2026 21:11

Pull request was closed

@Gerrrt
Gerrrt deleted the gerrrt/kali-cloud-init-first-boot-1127 branch October 14, 2026 11:09
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