Files
loc_az_hci/scripts/vm-management/configure/setup-vms-complete.sh
defiQUG c39465c2bd
Some checks failed
Test / test (push) Has been cancelled
Initial commit: loc_az_hci (smom-dbis-138 excluded via .gitignore)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 09:04:46 -08:00

109 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
source ~/.bashrc
# Complete VM Setup: Template + Install Scripts
# This is the main script that orchestrates the entire process
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
log_step() {
echo -e "${BLUE}[STEP]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR/.."
main() {
echo "========================================="
echo "Complete VM Setup with Templates & Scripts"
echo "========================================="
echo ""
log_step "This script will:"
echo " 1. Check for Cloud-Init template"
echo " 2. Create VMs from template (if needed)"
echo " 3. Apply install scripts to each VM"
echo ""
read -p "Continue? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
log_info "Cancelled"
exit 0
fi
# Step 1: Check for template
log_step "Step 1: Checking for Cloud-Init template..."
log_warn "Template check not automated yet"
log_info "Ensure you have created template: ubuntu-24.04-cloudinit"
log_info "See: scripts/create-proxmox-template.sh"
echo ""
read -p "Template ready? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
log_error "Please create template first"
exit 1
fi
# Step 2: Create VMs from template
log_step "Step 2: Creating VMs from template..."
if [ -f "scripts/create-vms-from-template.sh" ]; then
log_info "Running: scripts/create-vms-from-template.sh"
./scripts/create-vms-from-template.sh || log_warn "VM creation had issues"
else
log_error "Script not found: scripts/create-vms-from-template.sh"
exit 1
fi
echo ""
# Step 3: Wait for VMs to boot
log_step "Step 3: Waiting for VMs to boot..."
log_info "VMs need time to boot and complete Cloud-Init setup"
log_info "This may take 5-10 minutes"
echo ""
read -p "Wait 5 minutes, then press Enter to continue..."
# Step 4: Apply install scripts
log_step "Step 4: Applying install scripts to VMs..."
if [ -f "scripts/apply-install-scripts.sh" ]; then
log_info "Running: scripts/apply-install-scripts.sh"
./scripts/apply-install-scripts.sh || log_warn "Some scripts may have failed"
else
log_error "Script not found: scripts/apply-install-scripts.sh"
exit 1
fi
echo ""
log_info "========================================="
log_info "Setup Complete!"
log_info "========================================="
echo ""
log_info "Next steps:"
echo " 1. Verify services are running on each VM"
echo " 2. Configure Cloudflare Tunnel (VM 100)"
echo " 3. Configure K3s cluster (VM 101)"
echo " 4. Complete Gitea setup (VM 102)"
echo " 5. Configure Grafana dashboards (VM 103)"
}
main "$@"