init
This commit is contained in:
commit
883f31932e
169 changed files with 5676 additions and 0 deletions
69
scripts/deploy.sh
Executable file
69
scripts/deploy.sh
Executable file
|
|
@ -0,0 +1,69 @@
|
|||
#!/bin/sh
|
||||
# Deploy a service to the local VMs.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/deploy.sh <service> # deploy service
|
||||
# scripts/deploy.sh <service> --skip docker,apache # skip dependencies
|
||||
# scripts/deploy.sh <service> --restore # restore "provisioned" first
|
||||
# scripts/deploy.sh <service> --restore initialized # restore specific snapshot first
|
||||
#
|
||||
# Examples:
|
||||
# scripts/deploy.sh bugzilla
|
||||
# scripts/deploy.sh bugzilla --skip docker,apache
|
||||
# scripts/deploy.sh prosody --restore
|
||||
# scripts/deploy.sh authentik --restore initialized
|
||||
set -eu
|
||||
. "$(dirname "$0")/env.sh"
|
||||
|
||||
service=""
|
||||
skip_tags=""
|
||||
restore_snapshot=""
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--skip)
|
||||
skip_tags="$2"
|
||||
shift 2
|
||||
;;
|
||||
--restore)
|
||||
restore_snapshot="${2:-provisioned}"
|
||||
if [ $# -ge 2 ] && case "$2" in -*) false;; *) true;; esac; then
|
||||
shift 2
|
||||
else
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option: $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
if [ -z "$service" ]; then
|
||||
service="$1"
|
||||
else
|
||||
echo "Unexpected argument: $1" >&2
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$service" ]; then
|
||||
echo "Usage: deploy.sh <service> [--skip tags] [--restore [snapshot]]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$restore_snapshot" ]; then
|
||||
echo "==> Restoring to '$restore_snapshot'"
|
||||
"$SCRIPT_DIR/vm/restore.sh" "$restore_snapshot"
|
||||
fi
|
||||
|
||||
echo "==> Deploying: $service"
|
||||
if [ -n "$skip_tags" ]; then
|
||||
ansible-playbook -i "$INVENTORY" "$PLAYBOOK" --vault-password-file "$VAULT_PASS" \
|
||||
--tags "$service" --skip-tags "$skip_tags"
|
||||
else
|
||||
ansible-playbook -i "$INVENTORY" "$PLAYBOOK" --vault-password-file "$VAULT_PASS" \
|
||||
--tags "$service"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue