diff options
author | ismaelbouyaf <ismael.bouya@fretlink.com> | 2022-03-21 17:46:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-21 17:46:58 +0100 |
commit | 2f5634ede6c4ad01f7a9d34407324459629c1856 (patch) | |
tree | f21120bf0a6e7bee5d2e7a3aebdf14f29538e0f7 /files | |
parent | 30a577fc43ef49e5e9925bc82116a2bd47f9a842 (diff) | |
parent | d58fd11546cd378ff4eba6227adc10f8c06c386a (diff) | |
download | ansible-rundeck-jobs-master.tar.gz ansible-rundeck-jobs-master.tar.zst ansible-rundeck-jobs-master.zip |
Add an option to remove existing keys that are not declared in ansible
Diffstat (limited to 'files')
-rwxr-xr-x | files/fetch_keys.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/files/fetch_keys.sh b/files/fetch_keys.sh new file mode 100755 index 0000000..e15dc12 --- /dev/null +++ b/files/fetch_keys.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | set -euo pipefail | ||
4 | |||
5 | BASE_URL="$1" | ||
6 | TOKEN="$2" | ||
7 | BASE_PATH="$3" | ||
8 | |||
9 | list_path_rec() { | ||
10 | path="$1" | ||
11 | result=$(curl -ks "$BASE_URL/storage/$path?authtoken=$TOKEN") | ||
12 | |||
13 | case "$(echo "$result" | jq -r .type)" in | ||
14 | "file") echo "$result" | jq -r .path | sed -e "s@^$BASE_PATH/@@" | ||
15 | ;; | ||
16 | "directory") | ||
17 | echo "$result" | jq -r ".resources[]|.path" | while read p; do list_path_rec "$p"; done | ||
18 | ;; | ||
19 | esac | ||
20 | } | ||
21 | |||
22 | list_path_rec "$BASE_PATH" | ||