#!/bin/sh # Deploy a service to the local VMs. # # Usage: # scripts/deploy.sh # deploy service # scripts/deploy.sh --skip docker,apache # skip dependencies # scripts/deploy.sh --restore # restore "provisioned" first # scripts/deploy.sh --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 [--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