From b129f0383701d787dcbd1ab37ae10fa2609c7715 Mon Sep 17 00:00:00 2001 From: oskar Date: Sun, 17 May 2026 21:09:06 +0200 Subject: [PATCH] Fix stability agent fleet deploy scripts --- docs/stability-agent-rollout.md | 13 +++-- scripts/deploy/deploy-stability-agent.sh | 62 ++++++++++++++---------- services/stability-agent/deploy-local.sh | 20 +++++++- 3 files changed, 64 insertions(+), 31 deletions(-) diff --git a/docs/stability-agent-rollout.md b/docs/stability-agent-rollout.md index 8facc6f..6a0093e 100644 --- a/docs/stability-agent-rollout.md +++ b/docs/stability-agent-rollout.md @@ -13,22 +13,25 @@ Previously, the `stability-agent` had `NODE_NAME` defaulted to `chelsty` and was ## 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 # Print commands ./scripts/deploy/deploy-stability-agent.sh -# Deploy via SSH (requires SSH access to the node) +# Deploy via SSH (executes ssh oskar@) ./scripts/deploy/deploy-stability-agent.sh --ssh ``` ### Manual Steps per Node The manual steps are encapsulated in `services/stability-agent/deploy-local.sh`. On the target node: ```bash -cd ~/homelab-codex-ws -git pull +cd /home/oskar/homelab-codex-ws +git fetch origin +git checkout master +git pull origin master cd services/stability-agent -./deploy-local.sh +./deploy-local.sh ``` ## Verification diff --git a/scripts/deploy/deploy-stability-agent.sh b/scripts/deploy/deploy-stability-agent.sh index b97528b..51f937d 100755 --- a/scripts/deploy/deploy-stability-agent.sh +++ b/scripts/deploy/deploy-stability-agent.sh @@ -1,43 +1,55 @@ #!/usr/bin/env bash # deploy-stability-agent.sh - Helper to deploy stability-agent (print or SSH) -TARGET=$1 +NODE=$1 MODE="print" -REPO_PATH="~/homelab-codex-ws" +[[ "$2" == "--ssh" ]] && MODE="ssh" -if [[ "$2" == "--ssh" ]]; then - MODE="ssh" -fi - -if [[ -z "$TARGET" ]]; then +if [[ -z "$NODE" ]]; then echo "Usage: $0 [--ssh]" echo "Supported nodes: chelsty, piha, solaria, vps" exit 1 fi -case "$TARGET" in - chelsty|piha|solaria|vps) - ;; +case "$NODE" in + 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" exit 1 ;; esac -if [[ "$MODE" == "ssh" ]]; then - echo "--- Deploying to $TARGET via SSH ---" - ssh "$TARGET" "cd $REPO_PATH && git fetch origin && git checkout master && git pull && cd services/stability-agent && ./deploy-local.sh" +echo "HOST: $NODE" +echo "MODE: $MODE" +echo "TARGET: $TARGET" + +REPO_PATH="/home/oskar/homelab-codex-ws" + +if [[ "$NODE" == "solaria" ]]; then + if [[ "$MODE" == "ssh" ]]; then + echo "--- Running local deployment for solaria ---" + cd "$REPO_PATH" && git fetch origin && git checkout master && git pull origin master && cd services/stability-agent && ./deploy-local.sh solaria + else + echo "# --- Deployment commands for solaria ---" + echo "cd $REPO_PATH" + echo "git fetch origin" + echo "git checkout master" + echo "git pull origin master" + echo "cd services/stability-agent" + echo "./deploy-local.sh solaria" + fi else - echo "# --- Deployment commands for $TARGET ---" - echo "cd $REPO_PATH" - echo "git fetch origin" - echo "git checkout master" - echo "git pull" - echo "cd services/stability-agent" - echo "./deploy-local.sh" - echo "" - echo "# Notes:" - echo "# - Run './deploy-local.sh' on the target host." - echo "# - Ensure /opt/homelab/state and /opt/homelab/events exist on the host." + # Remote nodes + 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 diff --git a/services/stability-agent/deploy-local.sh b/services/stability-agent/deploy-local.sh index 09d5117..cef3c9e 100755 --- a/services/stability-agent/deploy-local.sh +++ b/services/stability-agent/deploy-local.sh @@ -4,8 +4,26 @@ 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 " + 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 -NODE_NAME=${NODE_NAME:-$(hostname)} REDIS_HOST=${REDIS_HOST:-100.108.208.3} REDIS_PORT=${REDIS_PORT:-6379} REDIS_ENABLED=${REDIS_ENABLED:-true}