Add script to read ansible vault password from pass
This commit is contained in:
parent
b50d761251
commit
0f3d24a0e0
1 changed files with 29 additions and 0 deletions
29
.bin/ansible-vault-pass.sh
Executable file
29
.bin/ansible-vault-pass.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
project_dir="$(git rev-parse --show-toplevel)"
|
||||
|
||||
if [ -z "$project_dir" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
url="$(git remote get-url origin)"
|
||||
|
||||
re="^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+)(.git)*$"
|
||||
|
||||
if [[ $url =~ $re ]]; then
|
||||
#protocol=${BASH_REMATCH[1]}
|
||||
#separator=${BASH_REMATCH[2]}
|
||||
#hostname=${BASH_REMATCH[3]}
|
||||
user=${BASH_REMATCH[4]}
|
||||
repo=$(basename -s .git "${BASH_REMATCH[5]}")
|
||||
fi
|
||||
|
||||
project="$user/$repo"
|
||||
|
||||
if ! pass "ansible/$project" >/dev/null 2>&1; then
|
||||
echo "Error: ansible/$project not found in pass" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pass "ansible/$project"
|
||||
|
Loading…
Reference in a new issue