Files
server-infra/scripts/deploy.sh
T
2026-07-06 15:34:49 -05:00

70 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$REPO_ROOT"
LIMIT=""
EXTRA_ARGS=()
EXTRA_VARS=()
usage() {
cat <<EOF
Usage: $(basename "$0") [HOST] [OPTIONS]
Deploy application with deploy-apps.yml (Phase 2 stub).
HOST Optional. Limit to one host: adama, roslin, or desktop.
Options:
--check Dry run
--diff Show diffs
--extra-vars V Pass extra vars (e.g. app_ref=abc123)
-h, --help Show this help
Examples:
$(basename "$0") adama --check
$(basename "$0") --extra-vars app_ref=master
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
usage
exit 0
;;
--check)
EXTRA_ARGS+=(--check)
shift
;;
--diff)
EXTRA_ARGS+=(--diff)
shift
;;
--extra-vars)
EXTRA_VARS+=(-e "$2")
shift 2
;;
adama|roslin|desktop)
LIMIT="$1"
shift
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
CMD=(ansible-playbook playbooks/deploy-apps.yml "${EXTRA_ARGS[@]}" "${EXTRA_VARS[@]}")
if [[ -n "$LIMIT" ]]; then
CMD+=(--limit "$LIMIT")
echo "==> Deploying to: $LIMIT"
else
echo "==> Deploying to all webservers"
fi
exec "${CMD[@]}"