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,103 @@
|
||||
# shellcheck shell=bash
|
||||
# Shared command dispatcher. Sourced by each platform's lab.sh after the
|
||||
# command implementations and before anything runs.
|
||||
#
|
||||
# The platform provides: LAB_DIR, CONTENT_DIR, PLATFORM, and its backend file
|
||||
# at $LAB_DIR/backends/<PLATFORM>.sh.
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Norbourg lab ${LAB_SH_VERSION} — ${PLATFORM} platform
|
||||
|
||||
Usage: ./lab.sh [options] <command>
|
||||
|
||||
Options:
|
||||
--strict treat check warnings as failures
|
||||
-v, --verbose extra detail
|
||||
-h, --help this text
|
||||
--version print the version
|
||||
|
||||
Commands:
|
||||
check preflight: host, storage, network, configuration
|
||||
init create the storage layout and the runtime venv if needed
|
||||
isos download the Windows media
|
||||
seeds render unattend files and pack the seed ISOs
|
||||
build create the VMs and run the unattended installs
|
||||
provision run the role stages (--role NAME for a single VM)
|
||||
web assemble the site; --sync publishes it to FS01
|
||||
snapshot freeze a clean baseline
|
||||
reset revert to the baseline and start
|
||||
up, down start / stop the VMs
|
||||
status VM table
|
||||
vnc open a console on a VM
|
||||
doctor end-to-end health check
|
||||
answers print the instructor walkthrough
|
||||
destroy remove the VMs and generated artifacts
|
||||
EOF
|
||||
case $PLATFORM in
|
||||
proxmox) printf ' peers generate WireGuard configs for participants\n' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
planned() {
|
||||
warn "'$1' is not implemented on this platform"
|
||||
return 3
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------ arguments
|
||||
cmd=""
|
||||
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
--strict) STRICT=1; shift ;;
|
||||
-v|--verbose) VERBOSE=1; shift ;;
|
||||
-h|--help|help) usage; exit 0 ;;
|
||||
--version) printf '%s\n' "$LAB_SH_VERSION"; exit 0 ;;
|
||||
--) shift; break ;;
|
||||
-*)
|
||||
# Before the command this is a typo; after it, the flag belongs to the verb.
|
||||
[[ -z $cmd ]] && die "unknown option: $1 (try --help)"
|
||||
break
|
||||
;;
|
||||
*)
|
||||
# First positional is the command; everything after it belongs to the verb
|
||||
# (peers wants a list of names, provision wants --role NAME).
|
||||
if [[ -z $cmd ]]; then cmd=$1; shift; fi
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z $cmd ]]; then
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
load_config
|
||||
|
||||
backend_file="$LAB_DIR/backends/${BACKEND}.sh"
|
||||
[[ -r $backend_file ]] || die "no backend '${BACKEND}' for the ${PLATFORM} platform (looked for ${backend_file})"
|
||||
# shellcheck disable=SC1090
|
||||
source "$backend_file"
|
||||
|
||||
# ------------------------------------------------------------------ dispatch
|
||||
case $cmd in
|
||||
check) cmd_check "$@" || exit $? ;;
|
||||
init) cmd_init "$@" ;;
|
||||
isos) cmd_isos "$@" ;;
|
||||
seeds) cmd_seeds "$@" ;;
|
||||
web) cmd_web "$@" ;;
|
||||
build) cmd_build "$@" ;;
|
||||
up) cmd_up "$@" ;;
|
||||
down) cmd_down "$@" ;;
|
||||
status) cmd_status "$@" ;;
|
||||
vnc) cmd_vnc "$@" ;;
|
||||
provision) cmd_provision "$@" ;;
|
||||
snapshot) cmd_snapshot "$@" ;;
|
||||
reset) cmd_reset "$@" ;;
|
||||
doctor) cmd_doctor "$@" ;;
|
||||
answers) cmd_answers "$@" ;;
|
||||
destroy) cmd_destroy "$@" ;;
|
||||
peers) cmd_peers "$@" ;;
|
||||
*) die "unknown command: ${cmd} (try --help)" ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user