Phase 3: unattended install, seed ISOs and VM lifecycle

autounattend template (q35/AHCI/e1000, no virtio injection), per-VM seed
ISOs with a bootstrap that configures the static IP, enables WinRM/RDP and
chains into the role script. build --dry-run, up/down/status/vnc verbs.

Static addressing happens in PowerShell rather than in the unattend file:
Microsoft-Windows-TCPIP matches adapters by connection name and fails
silently when the name differs.
This commit is contained in:
2026-10-21 18:46:31 -04:00
parent 5a8f988f30
commit c66b5641b6
11 changed files with 719 additions and 24 deletions
+61
View File
@@ -0,0 +1,61 @@
# Norbourg lab — first-boot bootstrap, runs once from the seed ISO.
# The unattend file creates the account and triggers this; everything that
# touches the network happens here because unattend TCPIP settings fail
# silently when the adapter name does not match.
$ErrorActionPreference = 'Stop'
$base = 'C:\norbourg'
New-Item -ItemType Directory -Force -Path $base | Out-Null
Start-Transcript -Path "$base\bootstrap.log" -Append | Out-Null
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
. (Join-Path $here 'config.ps1')
Write-Host "bootstrap: host=$($Config.Hostname) role=$($Config.Role) ip=$($Config.IP)"
# ------------------------------------------------------------------ network
$nic = Get-NetAdapter |
Where-Object { $_.Status -eq 'Up' -and $_.InterfaceDescription -notmatch 'Loopback' } |
Select-Object -First 1
if (-not $nic) {
Write-Host 'bootstrap: no up adapter, network step skipped'
} else {
Remove-NetIPAddress -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue
Remove-NetRoute -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue
New-NetIPAddress -InterfaceIndex $nic.ifIndex `
-IPAddress $Config.IP -PrefixLength $Config.Prefix `
-DefaultGateway $Config.Gateway | Out-Null
Set-DnsClientServerAddress -InterfaceIndex $nic.ifIndex -ServerAddresses $Config.DNS
Set-NetConnectionProfile -InterfaceIndex $nic.ifIndex -NetworkCategory Private -ErrorAction SilentlyContinue
Write-Host "bootstrap: $($nic.Name) -> $($Config.IP)/$($Config.Prefix)"
}
# ------------------------------------------------------------------ WinRM
# The host provisions over WinRM; no guest agent needed for that.
Enable-PSRemoting -SkipNetworkProfileCheck -Force | Out-Null
Set-NetFirewallRule -DisplayGroup 'Windows Remote Management' -Enabled True -Profile Any -ErrorAction SilentlyContinue
# RDP: useful for the instructor when a step misbehaves.
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\Terminal Server' `
-Name fDenyTSConnections -Value 0
Enable-NetFirewallRule -DisplayGroup 'Remote Desktop' -ErrorAction SilentlyContinue
# ------------------------------------------------------------------ marker
"$env:COMPUTERNAME|$($Config.Role)|$($Config.IP)|$((Get-Date).ToString('s'))" |
Set-Content -Path "$base\stamp.txt" -Encoding ascii
# ------------------------------------------------------------------ role
$role = Join-Path $here "roles\$($Config.Role).ps1"
if (Test-Path $role) {
Write-Host "bootstrap: running role $($Config.Role)"
& $role
} else {
Write-Host "bootstrap: no role script for '$($Config.Role)' yet (phase 5)"
}
Write-Host 'bootstrap: done'
Stop-Transcript | Out-Null