add rollback script and vault helper

This commit is contained in:
Stefan Weber 2026-01-20 11:00:00 +00:00
parent eec271fb5e
commit e0583c38fb
2 changed files with 24 additions and 0 deletions

9
lib/vault.sh Normal file
View file

@ -0,0 +1,9 @@
#!/bin/bash
# Thin wrapper around vault kv get for scripts that need secrets at runtime.
# Usage: source lib/vault.sh && vault_get "secret/nexus/db" "password"
vault_get() {
local path="$1"
local field="$2"
vault kv get -field="$field" "$path"
}

15
scripts/rollback.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
# Roll back the production deployment to the previous release.
set -euo pipefail
DEPLOY_HOST="prod.nexus.local"
PREVIOUS=$(ssh deploy@"$DEPLOY_HOST" "ls -1dt /opt/releases/*/ | sed -n '2p'")
if [ -z "$PREVIOUS" ]; then
echo "[rollback] No previous release found." >&2
exit 1
fi
echo "[rollback] Rolling back to: $PREVIOUS"
ssh deploy@"$DEPLOY_HOST" "ln -sfn '$PREVIOUS' /opt/app && systemctl restart nexus-app"
echo "[rollback] Done."