#!/bin/bash if [ -z "$1" ] || [ -z "$2" ]; then echo "$0 " exit 1 fi command="$1" file="$2" shift 2 file=$(realpath --relative-to "${BASH_SOURCE%/*}" "$file") env_group=${file%%/*} if [ $env_group = "files" ]; then tmp=$(realpath --relative-to "${BASH_SOURCE%/*}/files" "$file") env_group=${tmp%%/*} fi cd "${BASH_SOURCE%/*}" source common/utils.sh vault_environment__set "$env_group" || exit 1 exec ansible-vault "$command" "$file"