Provisioning fixes: auth-based readiness, domain join guards, site push

- wait for WinRM with an authenticated call, not a TCP probe: the port opens
  before the service can authenticate
- skip promotion/join when the machine is already there, so provision is
  idempotent
- probe the domain with System.DirectoryServices: Get-ADDomain needs RSAT,
  which a member server does not have
- passwords must not contain the account name (Legault2024! is rejected)
- Web-Dir-Browsing is the real feature name
- push the site over SMB from C$: WinRM caps the command line at 8 KB
This commit is contained in:
2026-10-21 20:02:43 -04:00
parent bb8a6a6eb0
commit 645adea875
9 changed files with 83 additions and 34 deletions
+42 -4
View File
@@ -4,6 +4,14 @@
cmd_web() {
local site="$LAB_DIR/web/site" seed="$LAB_DIR/web/seed"
local sync=0 arg
for arg in "$@"; do
case $arg in
--sync) sync=1 ;;
-h|--help) info "usage: ./lab.sh web [--sync]"; return 0 ;;
*) die "unknown argument: $arg" ;;
esac
done
step "assemble"
python3 "$LAB_DIR/scripts/prepare_site.py" || die "site assembly failed"
@@ -21,8 +29,38 @@ cmd_web() {
printf ' %-34s %s\n' "index.html" \
"$([[ -f $site/index.html ]] && echo present || echo MISSING)"
printf '\n'
ok "web root ready: ${site#$LAB_DIR/}"
info " preview: python3 -m http.server 8080 --directory ${site#$LAB_DIR/}"
info " sync to FS01 arrives in phase 7"
if (( ! sync )); then
printf '\n'
ok "web root ready: ${site#$LAB_DIR/}"
info " preview: python3 -m http.server 8080 --directory ${site#$LAB_DIR/}"
info " push to FS01: ./lab.sh web --sync"
return 0
fi
_web_sync "$site"
}
_web_sync() {
local site=$1
local i ip remote='C:\\norbourg\\site'
i=$(vm_index fs01) || die "fs01 is not defined in lab.conf"
ip=${VM_IPS[$i]}
step "push to fs01 ($ip)"
tcp_open "$ip" 445 || die "fs01 SMB is not reachable — is it provisioned?"
have_cmd smbclient || die "smbclient is required to push the site"
# Bulk copy goes over SMB: WinRM caps the command line at ~8 KB.
smbclient "//$ip/C\$" -W "$NETBIOS" \
-U "$LAB_USER%$LAB_ADMIN_PASSWORD" \
-c "prompt OFF; recurse ON; mkdir norbourg; mkdir norbourg\\site; lcd $site; cd norbourg\\site; mput *" \
>/dev/null 2>&1 || true
_wait_winrm "$ip" 120 || die "fs01 did not answer WinRM"
_winrm_retry "$ip" ps "Copy-Item -Path 'C:\\norbourg\\site\\*' -Destination 'C:\\inetpub\\wwwroot' -Recurse -Force; Test-Path 'C:\\inetpub\\wwwroot\\index.html'" \
| grep -qi true || die "copy failed on fs01"
ok "site published to C:\\inetpub\\wwwroot"
info " http://10.10.10.20/ · http://www.norbourg.lab/"
}