session1/ now holds the whole live lab (content, platforms, docs, answer key, README); session2/ keeps the design for the second workshop. The root README indexes both and states that session2 modifies session1 rather than duplicating it. build-bundle.sh builds from session1 and still produces a flat archive, so the documented paths inside a deployment (platforms/<p>/lab.sh) are unchanged. .gitignore follows the move.
62 lines
2.1 KiB
Bash
62 lines
2.1 KiB
Bash
# shellcheck shell=bash
|
|
# cmd_provision — run the role stages inside each guest.
|
|
#
|
|
# The role scripts travel on the seed ISO and bootstrap copies them to
|
|
# C:\norbourg, so provisioning never transfers files: it only asks the guest
|
|
# to run a script and waits for its .done marker. The transport (WinRM or the
|
|
# QEMU guest agent) lives in the backend.
|
|
|
|
cmd_provision() {
|
|
local only=""
|
|
while (( $# > 0 )); do
|
|
case $1 in
|
|
--role) only=$2; shift 2 ;;
|
|
-h|--help) info "usage: ./lab.sh provision [--role NAME]"; return 0 ;;
|
|
*) die "unknown argument: $1" ;;
|
|
esac
|
|
done
|
|
|
|
: "${LAB_SAFE_MODE_PASSWORD:?LAB_SAFE_MODE_PASSWORD is not set in lab.conf}"
|
|
|
|
local i name role script marker
|
|
for i in "${!VM_NAMES[@]}"; do
|
|
name=${VM_NAMES[$i]}
|
|
role=${VM_ROLES[$i]}
|
|
script="C:\\norbourg\\roles\\${role}.ps1"
|
|
|
|
[[ -n $only && $only != "$name" && $only != "$role" ]] && continue
|
|
|
|
step "$name ($role)"
|
|
if [[ $role != dc01 ]]; then
|
|
backend_ready dc01 300 || die "dc01 is not reachable — provision dc01 first"
|
|
fi
|
|
|
|
backend_ready "$name" 600 || { fail "$name: guest agent/WinRM unreachable"; return 1; }
|
|
|
|
backend_start "$name" "$script" || die "$name: could not start ${role}.ps1"
|
|
marker=$(backend_wait "$name" "$script" 3600) || {
|
|
fail "$name: ${role}.ps1 did not finish"
|
|
return 1
|
|
}
|
|
[[ $marker == FAIL* ]] && { fail "$name: ${role}.ps1 failed — $marker"; return 1; }
|
|
ok "$name: $marker"
|
|
|
|
if [[ -f $CONTENT_DIR/windows/roles/${role}-post.ps1 ]]; then
|
|
info " waiting for the guest to come back"
|
|
backend_ready "$name" 900 || { fail "$name: did not come back after reboot"; return 1; }
|
|
|
|
script="C:\\norbourg\\roles\\${role}-post.ps1"
|
|
backend_start "$name" "$script" || { fail "$name: could not start the post stage"; return 1; }
|
|
marker=$(backend_wait "$name" "$script" 3600) || {
|
|
fail "$name: ${role}-post.ps1 did not finish"
|
|
return 1
|
|
}
|
|
[[ $marker == FAIL* ]] && { fail "$name: ${role}-post.ps1 failed — $marker"; return 1; }
|
|
ok "$name: $marker"
|
|
fi
|
|
done
|
|
|
|
printf '\n'
|
|
ok "provisioning complete"
|
|
}
|