proxmox: reboot once after the install so the guest agent can connect

The agent MSI was installed at first logon, before the virtio-serial port
existed. The service started without a channel and Proxmox kept reporting
"guest agent is not running", which blocked provisioning at backend_ready.

- backend_finalize now waits for the first-logon bootstrap to finish
  (stamp.txt over SMB, which does not need the agent), detaches the
  installer ISO, reboots the VM once and waits for the agent to answer.
- bootstrap logs the pnputil and msiexec exit codes, so bootstrap.log says
  exactly what happened if it still fails.
- check requires smbclient (site sync + finalize) and python3.
- instructor guide: snapshot doubles disk usage, plan ~60 GB.
This commit is contained in:
2026-10-26 17:23:05 -04:00
parent bcc370d70f
commit 06a9034214
3 changed files with 42 additions and 3 deletions
+37 -1
View File
@@ -90,6 +90,9 @@ backend_check() {
_c_fail "genisoimage or xorriso required to build seed ISOs"
fi
have_cmd smbclient || _c_fail "smbclient required (apt install smbclient): site sync and install finalize"
have_cmd python3 || _c_fail "python3 required to read the guest agent output"
# participant Kali clones
local kali_count=${KALI_COUNT:-0}
if (( kali_count > 0 )); then
@@ -436,10 +439,43 @@ CONF
# After a successful install, stop booting from the installer CD: otherwise
# every boot waits five seconds and a stray keypress re-enters Setup.
backend_finalize() {
local name=$1 vmid
local name=$1 vmid ip deadline
vmid=$(pve_vmid "$name")
ip=$(pve_ip "$name")
qm set "$vmid" --boot 'order=sata0' --delete ide2 >/dev/null 2>&1 || true
ok "$(printf '%-6s boots from disk (installer ISO detached)' "$name")"
# WinRM answers while the first-logon bootstrap is still running (it
# enables remoting early). Rebooting before stamp.txt exists would abort
# the agent install, so wait for the end marker first. SMB is already up
# and, unlike the agent, does not depend on vioser.
if have_cmd smbclient; then
deadline=$(( SECONDS + 300 ))
while (( SECONDS < deadline )); do
smbclient "//$ip/C\$" -W "$NETBIOS" -U "$LAB_USER%$LAB_ADMIN_PASSWORD" \
-c 'ls norbourg\stamp.txt' >/dev/null 2>&1 && break
sleep 5
done
else
warn "smbclient missing: cannot wait for the bootstrap marker, pausing 60 s"
sleep 60
fi
# The virtio-serial port appears on the next boot: the agent installed at
# first logon started before its device existed and never connected, so
# Proxmox reports "guest agent is not running". Reboot once and wait.
qm reboot "$vmid" >/dev/null 2>&1 || qm start "$vmid" >/dev/null 2>&1 || true
deadline=$(( SECONDS + 300 ))
while (( SECONDS < deadline )); do
if _qga "$name" cmd.exe /c exit >/dev/null 2>&1; then
ok "$(printf '%-6s guest agent answering' "$name")"
return 0
fi
sleep 5
done
warn "$name: guest agent still silent after the post-install reboot"
return 1
}
# ------------------------------------------------------------------ kali