Files
proxmox/scripts/deployment/create-dbis-rtgs-sidecar-lxcs.sh
defiQUG 4ef9ca58ef
All checks were successful
Deploy to Phoenix / deploy (push) Successful in 6s
Deploy DBIS RTGS first-slice sidecars
2026-03-29 00:01:34 -07:00

80 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Create the three DBIS RTGS first-slice sidecar LXCs on r630-02.
# Usage:
# ./scripts/deployment/create-dbis-rtgs-sidecar-lxcs.sh [--dry-run]
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
HOST="${PROXMOX_HOST_R630_02:-${PROXMOX_R630_02:-192.168.11.12}}"
NETWORK="${NETWORK:-vmbr0}"
GATEWAY="${NETWORK_GATEWAY:-192.168.11.1}"
DNS="${DNS_PRIMARY:-1.1.1.1}"
STORAGE="${RTGS_SIDECAR_STORAGE:-thin3}"
TEMPLATE="${TEMPLATE_UBUNTU_24:-local:vztmpl/ubuntu-24.04-standard_24.04-1_amd64.tar.zst}"
SSH_OPTS="-o BatchMode=yes -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new"
DRY_RUN=false
if [[ "${1:-}" == "--dry-run" ]]; then
DRY_RUN=true
fi
SIDEcars=(
"5802 rtgs-scsm-1 192.168.11.89 4096 2 24"
"5803 rtgs-funds-1 192.168.11.90 4096 2 24"
"5804 rtgs-xau-1 192.168.11.92 4096 2 24"
)
resolve_template() {
if ssh $SSH_OPTS "root@$HOST" "pveam list local 2>/dev/null | grep -q 'ubuntu-24.04-standard'" 2>/dev/null; then
echo "local:vztmpl/ubuntu-24.04-standard_24.04-1_amd64.tar.zst"
elif ssh $SSH_OPTS "root@$HOST" "pveam list local 2>/dev/null | grep -q 'ubuntu-22.04-standard'" 2>/dev/null; then
echo "local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst"
else
echo "$TEMPLATE"
fi
}
TEMPLATE="$(resolve_template)"
echo "=== DBIS RTGS first-slice sidecar LXCs ==="
echo "Host: $HOST"
echo "Storage: $STORAGE"
echo "Template: $TEMPLATE"
echo
for spec in "${SIDEcars[@]}"; do
read -r VMID HOSTNAME IP MEMORY CORES ROOTFS_GB <<<"$spec"
if ssh $SSH_OPTS "root@$HOST" "pct status $VMID >/dev/null 2>&1"; then
echo "CT $VMID already exists on $HOST; skipping create."
continue
fi
CREATE_CMD="pct create $VMID $TEMPLATE \
--hostname $HOSTNAME \
--memory $MEMORY \
--cores $CORES \
--rootfs $STORAGE:${ROOTFS_GB} \
--net0 name=eth0,bridge=$NETWORK,ip=$IP/24,gw=$GATEWAY \
--features nesting=1,keyctl=1 \
--nameserver $DNS \
--onboot 1 \
--start 1 \
--unprivileged 0 \
--description 'DBIS RTGS first-slice sidecar LXC ($HOSTNAME)'"
if $DRY_RUN; then
echo "[DRY-RUN] $CREATE_CMD"
echo
continue
fi
echo "Creating CT $VMID ($HOSTNAME, $IP)..."
ssh $SSH_OPTS "root@$HOST" "$CREATE_CMD"
done
echo "Done."