Fix stability agent fleet deploy scripts

This commit is contained in:
oskar 2026-05-17 21:09:06 +02:00
parent b7faac00c5
commit b129f03837
3 changed files with 64 additions and 31 deletions

View file

@ -13,22 +13,25 @@ Previously, the `stability-agent` had `NODE_NAME` defaulted to `chelsty` and was
## Deployment ## Deployment
Use the helper script to deploy or generate commands: Use the helper script to deploy or generate commands. The script uses explicit Tailscale IPs for remote targets (piha, chelsty, vps) and runs locally for solaria.
```bash ```bash
# Print commands # Print commands
./scripts/deploy/deploy-stability-agent.sh <node-name> ./scripts/deploy/deploy-stability-agent.sh <node-name>
# Deploy via SSH (requires SSH access to the node) # Deploy via SSH (executes ssh oskar@<ip>)
./scripts/deploy/deploy-stability-agent.sh <node-name> --ssh ./scripts/deploy/deploy-stability-agent.sh <node-name> --ssh
``` ```
### Manual Steps per Node ### Manual Steps per Node
The manual steps are encapsulated in `services/stability-agent/deploy-local.sh`. On the target node: The manual steps are encapsulated in `services/stability-agent/deploy-local.sh`. On the target node:
```bash ```bash
cd ~/homelab-codex-ws cd /home/oskar/homelab-codex-ws
git pull git fetch origin
git checkout master
git pull origin master
cd services/stability-agent cd services/stability-agent
./deploy-local.sh ./deploy-local.sh <node-name>
``` ```
## Verification ## Verification

View file

@ -1,43 +1,55 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# deploy-stability-agent.sh - Helper to deploy stability-agent (print or SSH) # deploy-stability-agent.sh - Helper to deploy stability-agent (print or SSH)
TARGET=$1 NODE=$1
MODE="print" MODE="print"
REPO_PATH="~/homelab-codex-ws" [[ "$2" == "--ssh" ]] && MODE="ssh"
if [[ "$2" == "--ssh" ]]; then if [[ -z "$NODE" ]]; then
MODE="ssh"
fi
if [[ -z "$TARGET" ]]; then
echo "Usage: $0 <node-name> [--ssh]" echo "Usage: $0 <node-name> [--ssh]"
echo "Supported nodes: chelsty, piha, solaria, vps" echo "Supported nodes: chelsty, piha, solaria, vps"
exit 1 exit 1
fi fi
case "$TARGET" in case "$NODE" in
chelsty|piha|solaria|vps) piha) TARGET="100.108.208.3" ;;
;; chelsty) TARGET="100.122.201.22" ;;
vps) TARGET="100.95.58.48" ;;
solaria) TARGET="local" ;;
*) *)
echo "Error: Unknown node '$TARGET'" echo "Error: Unknown node '$NODE'"
echo "Supported nodes: chelsty, piha, solaria, vps" echo "Supported nodes: chelsty, piha, solaria, vps"
exit 1 exit 1
;; ;;
esac esac
echo "HOST: $NODE"
echo "MODE: $MODE"
echo "TARGET: $TARGET"
REPO_PATH="/home/oskar/homelab-codex-ws"
if [[ "$NODE" == "solaria" ]]; then
if [[ "$MODE" == "ssh" ]]; then if [[ "$MODE" == "ssh" ]]; then
echo "--- Deploying to $TARGET via SSH ---" echo "--- Running local deployment for solaria ---"
ssh "$TARGET" "cd $REPO_PATH && git fetch origin && git checkout master && git pull && cd services/stability-agent && ./deploy-local.sh" cd "$REPO_PATH" && git fetch origin && git checkout master && git pull origin master && cd services/stability-agent && ./deploy-local.sh solaria
else else
echo "# --- Deployment commands for $TARGET ---" echo "# --- Deployment commands for solaria ---"
echo "cd $REPO_PATH" echo "cd $REPO_PATH"
echo "git fetch origin" echo "git fetch origin"
echo "git checkout master" echo "git checkout master"
echo "git pull" echo "git pull origin master"
echo "cd services/stability-agent" echo "cd services/stability-agent"
echo "./deploy-local.sh" echo "./deploy-local.sh solaria"
echo "" fi
echo "# Notes:" else
echo "# - Run './deploy-local.sh' on the target host." # Remote nodes
echo "# - Ensure /opt/homelab/state and /opt/homelab/events exist on the host." SSH_CMD="ssh oskar@$TARGET 'cd $REPO_PATH && git fetch origin && git checkout master && git pull origin master && cd services/stability-agent && ./deploy-local.sh $NODE'"
if [[ "$MODE" == "ssh" ]]; then
echo "--- Deploying to $NODE ($TARGET) via SSH ---"
eval "$SSH_CMD"
else
echo "# --- Deployment commands for $NODE ---"
echo "$SSH_CMD"
fi
fi fi

View file

@ -4,8 +4,26 @@
set -e set -e
# Node resolution: positional argument takes precedence over NODE_NAME env
NODE_NAME=${1:-$NODE_NAME}
if [[ -z "$NODE_NAME" ]]; then
echo "Usage: $0 <node-name>"
echo "Example: $0 piha"
exit 1
fi
# Validation
case "$NODE_NAME" in
piha|chelsty|solaria|vps)
;;
*)
echo "Error: Invalid node '$NODE_NAME'. Must be one of: piha, chelsty, solaria, vps"
exit 1
;;
esac
# Default values # Default values
NODE_NAME=${NODE_NAME:-$(hostname)}
REDIS_HOST=${REDIS_HOST:-100.108.208.3} REDIS_HOST=${REDIS_HOST:-100.108.208.3}
REDIS_PORT=${REDIS_PORT:-6379} REDIS_PORT=${REDIS_PORT:-6379}
REDIS_ENABLED=${REDIS_ENABLED:-true} REDIS_ENABLED=${REDIS_ENABLED:-true}