Skip to content

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

Merged
Gerrrt merged 1 commit into
mainfrom
gerrrt/kali-cloud-init-1127-v2
Oct 10, 2026
Merged

Gerrrt merged 1 commit into
mainfrom
gerrrt/kali-cloud-init-1127-v2

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Refs #1127. This replaces PR 1157, whose history carried a stray close keyword in a commit message.

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

On a clone's first boot, cloud-init's generator could be cut off before it
enabled cloud-init.target, leaving no user, no key and the template's
hostname. It happened on 2 of 7 first boots of template 910 on 2026-10-10:
garuda, and one of four reproduction clones. On garuda's first boot sslh's
generator, from kali-linux-headless, aborted beside it.

The Kali build now links cloud-init.target into multi-user.target, which
makes cloud-init start whatever cuts its generator off, and masks sslh's
generator with a /dev/null link, keeping the package. The cause is not
proved, so the two are one fix, proved together: after a rebuild of 910,
12 of 12 first boots of disposable clones ran cloud-init. Both template
sources share the build, so 902 gets it as well.

Garuda's runbook section 4 now expects a 910 built since then not to need
the reboot workaround, and the changelog has the counts. This replaces
PR 1157, whose history carried a stray close keyword.

Refs #1127.

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 focused systemd changes address the documented race, preserve package dependencies, and are supported by repeated clone testing.

0 open findings

What changed in this PR

Fixes intermittent Kali clone initialization failures by making cloud-init startup independent of its generator and suppressing the failing sslh generator.

Changes:

  • Statically enables cloud-init.target and masks the sslh generator.
  • Updates the analyst workstation recovery guidance.
  • Records the failure, fix, and validation results.
File Description
packer/​kali.pkr.hcl Applies the boot fix to both Kali templates.
docs/​runbooks/​build-the-analyst-workstation.md Updates first-boot troubleshooting guidance.
docs/​changelog.md Adds a dated incident and validation record.

🧠 Review effort: Balanced


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

@Gerrrt
Gerrrt merged commit 8125596 into main Oct 10, 2026
9 checks passed
@Gerrrt
Gerrrt deleted the gerrrt/kali-cloud-init-1127-v2 branch October 10, 2026 21:20
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