summaryrefslogtreecommitdiff
path: root/vault.sh
blob: e44bff92c81ae3146f08789767e5e1e73f183347 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash

if [ -z "$1" ] || [ -z "$2" ]; then
  echo "$0 <command> <file>"
  exit 1
fi
command="$1"
file="$2"
shift 2

file=$(realpath --relative-to "${BASH_SOURCE%/*}" "$file")
env_group=${file%%/*}

cd "${BASH_SOURCE%/*}"
source common/utils.sh
vault_environment__set "$env_group" || exit 1

exec ansible-vault "$command" "$file"