Split into qemu and proxmox platforms over a shared content tree
platforms/qemu and platforms/proxmox each have their own lab.sh and lab.conf; content/ holds everything shared (roles, seed, site, helpers). The dispatcher, preflight and command implementations are common and take platform differences from the backend. Proxmox backend: qm create with q35/SATA/e1000, ISOs and seed ISOs in an ISO storage, provisioning over qm guest exec (no Python packages needed on the host), template + clone for reset, and peers/ to emit WireGuard configs. The role scripts now ride on the seed ISO, so provisioning transfers nothing. build-bundle.sh produces a self-contained tarball per platform, for hosts that cannot reach the git server. Both configs are generic: no absolute path from this machine remains.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
# 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"
|
||||
}
|
||||
Reference in New Issue
Block a user