Update ansible-vault-manager to use .tar
This commit is contained in:
parent
8432b54eb0
commit
cbb51fef2b
1 changed files with 22 additions and 6 deletions
|
@ -1,11 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
project_dir="$(git rev-parse --show-toplevel)"
|
||||
action="${1:-show}"
|
||||
target="${2:-}"
|
||||
|
||||
if [ "$action" = "save" ]; then
|
||||
target="" # Save all files
|
||||
fi
|
||||
|
||||
if [ -z "$project_dir" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$project_dir" || exit 1
|
||||
|
||||
url="$(git remote get-url origin)"
|
||||
|
||||
re="^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+)(.git)*$"
|
||||
|
@ -26,24 +34,32 @@ if ! pass "ansible/$project" >/dev/null 2>&1; then
|
|||
fi
|
||||
|
||||
pass_content=$(pass "ansible/$project")
|
||||
pass_path=$project_dir/$(echo "$pass_content" | grep "path:" | cut -d' ' -f2-)
|
||||
pass_paths=()
|
||||
|
||||
grep_filter="^path:"
|
||||
if [ -n "$target" ]; then
|
||||
grep_filter="^path: $target$"
|
||||
fi
|
||||
while read -r pass_path; do
|
||||
pass_paths+=("$pass_path")
|
||||
done <<< "$(echo "$pass_content" | grep "$grep_filter" | cut -d' ' -f2-)"
|
||||
|
||||
|
||||
action="${1:-show}"
|
||||
case "$action" in
|
||||
show)
|
||||
echo "$pass_content" | head -n 1
|
||||
exit 0 ;;
|
||||
view)
|
||||
ansible-vault view "$pass_path"
|
||||
ansible-vault view "${pass_paths[@]}"
|
||||
exit 0 ;;
|
||||
edit)
|
||||
ansible-vault edit "$pass_path"
|
||||
ansible-vault edit "${pass_paths[@]}"
|
||||
exit 0 ;;
|
||||
deploy)
|
||||
pass show "ansible/$project.file" > "$pass_path"
|
||||
pass show "ansible/$project.tar" | tar x
|
||||
exit 0 ;;
|
||||
save)
|
||||
pass insert -m "ansible/$project.file" < "$pass_path"
|
||||
tar c "${pass_paths[@]}" | pass insert -m "ansible/$project.tar"
|
||||
exit 0 ;;
|
||||
pass-edit)
|
||||
pass edit "ansible/$project"
|
||||
|
|
Loading…
Reference in a new issue