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,44 @@
|
||||
# Norbourg lab — shared helpers for role scripts.
|
||||
# Every role script writes a "<script>.done" marker so the host can wait
|
||||
# without parsing output, and so a failure is visible instead of silent.
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
|
||||
function Get-LabBase { 'C:\norbourg' }
|
||||
|
||||
function Write-LabLog {
|
||||
param([string]$Message)
|
||||
$line = "{0} {1}" -f (Get-Date -Format 'HH:mm:ss'), $Message
|
||||
Write-Host $line
|
||||
Add-Content -Path (Join-Path (Get-LabBase) 'provision.log') -Value $line
|
||||
}
|
||||
|
||||
function Complete-Stage {
|
||||
param([string]$Path, [string]$Message = 'ok')
|
||||
Set-Content -Path "$Path.done" -Value $Message -Encoding ascii
|
||||
Write-LabLog "stage done: $Message"
|
||||
}
|
||||
|
||||
function Fail-Stage {
|
||||
param([string]$Path, [string]$Message)
|
||||
Set-Content -Path "$Path.done" -Value "FAIL $Message" -Encoding ascii
|
||||
Write-LabLog "stage failed: $Message"
|
||||
throw $Message
|
||||
}
|
||||
|
||||
function Wait-ForDomain {
|
||||
param([int]$TimeoutSeconds = 600)
|
||||
$deadline = (Get-Date).AddSeconds($TimeoutSeconds)
|
||||
# Get-ADDomain needs the AD PowerShell module, which only exists on the DC.
|
||||
# System.DirectoryServices works on any domain-joined machine.
|
||||
while ((Get-Date) -lt $deadline) {
|
||||
try {
|
||||
$null = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
|
||||
return
|
||||
} catch {
|
||||
Start-Sleep -Seconds 10
|
||||
}
|
||||
}
|
||||
throw 'domain services did not come up in time'
|
||||
}
|
||||
Reference in New Issue
Block a user