64 lines
4.3 KiB
Bash
64 lines
4.3 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Create remaining nodes with correct storage/templates
|
||
|
|
set -euo pipefail
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||
|
|
source "$PROJECT_ROOT/config/ip-addresses.conf"
|
||
|
|
TEMPLATE="local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst"
|
||
|
|
NETWORK="vmbr0"
|
||
|
|
GATEWAY="${NETWORK_GATEWAY:-192.168.11.1}"
|
||
|
|
GREEN='\033[0;32m'
|
||
|
|
YELLOW='\033[1;33m'
|
||
|
|
RED='\033[0;31m'
|
||
|
|
BLUE='\033[0;34m'
|
||
|
|
NC='\033[0m'
|
||
|
|
log() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||
|
|
success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
||
|
|
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||
|
|
error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||
|
|
exists() {
|
||
|
|
local vmid=$1 host=$2
|
||
|
|
ssh -o StrictHostKeyChecking=no root@${host} "pct list 2>/dev/null | grep -q '^[[:space:]]*$vmid[[:space:]]' && echo 'yes' || echo 'no'"
|
||
|
|
}
|
||
|
|
create() {
|
||
|
|
local vmid=$1 hostname=$2 ip=$3 mem=$4 cores=$5 disk=$6 desc="$7" host=$8 storage=$9
|
||
|
|
if [[ "$(exists $vmid $host)" == "yes" ]]; then
|
||
|
|
warn "Container $vmid already exists, skipping..."
|
||
|
|
return 0
|
||
|
|
fi
|
||
|
|
log "Creating $vmid: $hostname ($ip) on $host using storage $storage..."
|
||
|
|
ssh -o StrictHostKeyChecking=no root@${host} "pct create $vmid $TEMPLATE --hostname $hostname --memory $((mem * 1024)) --cores $cores --rootfs $storage:${disk} --net0 name=eth0,bridge=$NETWORK,ip=$ip/24,gw=$GATEWAY --description \"$desc\" --start 1 --onboot 1 --unprivileged 0 2>&1 | grep -v 'WARNING: Ignoring duplicate' || true"
|
||
|
|
if [[ "$(exists $vmid $host)" == "yes" ]]; then
|
||
|
|
success "Container $vmid created successfully"
|
||
|
|
return 0
|
||
|
|
else
|
||
|
|
error "Failed to create container $vmid"
|
||
|
|
return 1
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
log "Creating remaining nodes with fixed storage/templates..."
|
||
|
|
# RPC nodes on r630-01 (use local-lvm)
|
||
|
|
create 2500 "besu-rpc-alltra-1" "${IP_SERVICE_172:-${IP_SERVICE_172:-192.168.11.172}}" 16 4 200 "Besu RPC ALLTRA 1" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 2501 "besu-rpc-alltra-2" "${IP_SERVICE_173:-${IP_SERVICE_173:-192.168.11.173}}" 16 4 200 "Besu RPC ALLTRA 2" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 2502 "besu-rpc-alltra-3" "${IP_SERVICE_174:-${IP_SERVICE_174:-192.168.11.174}}" 16 4 200 "Besu RPC ALLTRA 3" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 2503 "besu-rpc-hybx-1" "${IP_RPC_246:-${IP_RPC_246:-${IP_RPC_246:-192.168.11.246}}}" 16 4 200 "Besu RPC HYBX 1" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 2504 "besu-rpc-hybx-2" "${IP_RPC_247:-${IP_RPC_247:-${IP_RPC_247:-192.168.11.247}}}" 16 4 200 "Besu RPC HYBX 2" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 2505 "besu-rpc-hybx-3" "${IP_RPC_248:-${IP_RPC_248:-${IP_RPC_248:-192.168.11.248}}}" 16 4 200 "Besu RPC HYBX 3" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
wait
|
||
|
|
# Firefly nodes on r630-02 (use thin1-r630-02)
|
||
|
|
create 6202 "firefly-alltra-1" "${IP_FIREFLY_ALLTRA_1:-192.168.11.175}" 4 2 50 "Firefly ALLTRA 1" "${PROXMOX_HOST_R630_02}" "thin1-r630-02" &
|
||
|
|
create 6203 "firefly-alltra-2" "${IP_FIREFLY_ALLTRA_2:-192.168.11.176}" 4 2 50 "Firefly ALLTRA 2" "${PROXMOX_HOST_R630_02}" "thin1-r630-02" &
|
||
|
|
create 6204 "firefly-hybx-1" "${IP_SERVICE_24:-192.168.11.24}9" 4 2 50 "Firefly HYBX 1" "${PROXMOX_HOST_R630_02}" "thin1-r630-02" &
|
||
|
|
create 6205 "firefly-hybx-2" "${RPC_ALLTRA_1:-${RPC_ALLTRA_1:-192.168.11.250}}" 4 2 50 "Firefly HYBX 2" "${PROXMOX_HOST_R630_02}" "thin1-r630-02" &
|
||
|
|
wait
|
||
|
|
# Other services on r630-01 (use local-lvm)
|
||
|
|
create 5201 "cacti-alltra-1" "${IP_CACTI_ALLTRA:-192.168.11.177}" 4 2 50 "Cacti ALLTRA" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 5202 "cacti-hybx-1" "${RPC_ALI_1:-${RPC_ALI_1:-${RPC_ALI_1:-${RPC_ALI_1:-${RPC_ALI_1:-${RPC_ALI_1:-${RPC_ALI_1:-192.168.11.251}}}}}}}" 4 2 50 "Cacti HYBX" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 6001 "fabric-alltra-1" "${IP_FABRIC_ALLTRA:-192.168.11.178}" 8 4 100 "Fabric ALLTRA" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 6002 "fabric-hybx-1" "${RPC_ALI_2:-${RPC_ALI_2:-${RPC_ALI_2:-${RPC_ALI_2:-${RPC_ALI_2:-${RPC_ALI_2:-${RPC_ALI_2:-192.168.11.252}}}}}}}" 8 4 100 "Fabric HYBX" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 6401 "indy-alltra-1" "${IP_INDY_ALLTRA:-192.168.11.179}" 8 4 100 "Indy ALLTRA" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
create 6402 "indy-hybx-1" "${RPC_ALI_1_ALT:-${RPC_ALI_1_ALT:-${RPC_ALI_1_ALT:-192.168.11.253}}}" 8 4 100 "Indy HYBX" "${PROXMOX_HOST_R630_01}" "local-lvm" &
|
||
|
|
wait
|
||
|
|
log "Remaining node creation complete!"
|
||
|
|
success "Created remaining nodes"
|