Files
loc_az_hci/infrastructure/proxmox/deploy-network-config.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

143 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
# Deployment script for Proxmox network configuration
# This script should be run ON the Proxmox servers (ML110 or R630)
# It will validate, preview, and deploy the network configuration
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# 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_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
check_scripts() {
log_info "Checking script files..."
if [ ! -f "network-config.sh" ]; then
log_error "network-config.sh not found!"
exit 1
fi
if [ ! -f "validate-network-setup.sh" ]; then
log_error "validate-network-setup.sh not found!"
exit 1
fi
# Make scripts executable
chmod +x network-config.sh validate-network-setup.sh configure-proxmox-networking.sh
log_info "All scripts found and made executable"
}
deploy() {
log_info "========================================="
log_info "Proxmox Network Configuration Deployment"
log_info "========================================="
echo ""
# Check which script to use
USE_ALL_NICS="${USE_ALL_NICS:-false}"
NETWORK_SCRIPT="network-config.sh"
if [ "$USE_ALL_NICS" = "true" ] || [ -f "network-config-dhcp-all.sh" ]; then
if [ -f "network-config-dhcp-all.sh" ]; then
NETWORK_SCRIPT="network-config-dhcp-all.sh"
log_info "Using network-config-dhcp-all.sh (configure all NICs)"
fi
fi
# Step 1: Validation
log_info "Step 1: Validating system readiness..."
VALIDATION_OUTPUT=$(./validate-network-setup.sh 2>&1)
VALIDATION_EXIT=$?
echo "$VALIDATION_OUTPUT"
# Check if there are actual failures (not just warnings)
if [ $VALIDATION_EXIT -ne 0 ] || echo "$VALIDATION_OUTPUT" | grep -q "Failed: [1-9]"; then
log_error "Validation failed! Please fix the issues above before proceeding."
exit 1
fi
echo ""
# Step 2: Dry-run preview
log_info "Step 2: Previewing configuration (dry-run)..."
echo ""
if ! DRY_RUN=true ./"$NETWORK_SCRIPT"; then
log_error "Dry-run failed! Please check the configuration."
exit 1
fi
echo ""
# Step 3: Confirmation
log_warn "The configuration above will be applied."
log_warn "This will modify /etc/network/interfaces and may disconnect you temporarily."
echo ""
read -p "Do you want to proceed with deployment? (yes/no): " CONFIRM
if [ "$CONFIRM" != "yes" ]; then
log_info "Deployment cancelled by user."
exit 0
fi
echo ""
# Step 4: Deploy
log_info "Step 3: Deploying network configuration..."
if ! ./"$NETWORK_SCRIPT"; then
log_error "Deployment failed!"
log_error "You may need to restore from backup: /etc/network/interfaces.backup.*"
exit 1
fi
echo ""
# Step 5: Verification
log_info "Step 4: Verifying deployment..."
sleep 2
echo ""
log_info "Network Status:"
ip addr show vmbr0 2>/dev/null || log_warn "vmbr0 not up yet"
echo ""
ip addr show vmbr1 2>/dev/null || log_warn "vmbr1 not up yet"
echo ""
log_info "Routing Table:"
ip route show
echo ""
log_info "========================================="
log_info "Deployment Complete!"
log_info "========================================="
log_info "Please verify connectivity:"
log_info " - Check Proxmox web interface"
log_info " - Verify LAN connectivity: ping 192.168.1.1"
log_info " - Verify WAN connectivity: ping 8.8.8.8"
echo ""
log_info "If you need to rollback:"
log_info " sudo cp /etc/network/interfaces.backup.* /etc/network/interfaces"
log_info " sudo systemctl restart networking"
}
main() {
check_scripts
deploy
}
main "$@"