From 2a3efe7b5ce0c10f44304d52c0cd3fa9087208cf Mon Sep 17 00:00:00 2001 From: "Rune Juhl (Atea)" Date: Thu, 9 Nov 2023 14:33:51 +0100 Subject: [PATCH] Add ansible-encrypt --- ansible-encrypt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 ansible-encrypt diff --git a/ansible-encrypt b/ansible-encrypt new file mode 100755 index 0000000..3412996 --- /dev/null +++ b/ansible-encrypt @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Find ansible.cfg. We start in the current dir, look for the file, and go up +# one directory unless we find the file. +# +# Since we need a non-zero exit status until we've found the file, we simply +# pass the output to `grep` and match on anything. +while [[ $PWD != / ]] && ! find . -maxdepth 1 -name ansible.cfg -print -quit | + grep . 2>/dev/null 1>&2; do + cd .. +done + +if ! [[ -f ansible.cfg ]]; then + echo "Couldn't find ansible.cfg" + exit 1 +fi + +exec ansible-vault encrypt_string