2024-06-18 18:34:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
underline=`tput smul`
|
|
|
|
nounderline=`tput rmul`
|
|
|
|
bold=$(tput bold)
|
|
|
|
normal=$(tput sgr0)
|
|
|
|
|
|
|
|
echo "${bold}MatteZ02 / Infra / Protect${normal}"
|
|
|
|
action=$1
|
|
|
|
|
|
|
|
encrypt() {
|
|
|
|
echo "${underline}Encrypting...${nounderline}"
|
2024-12-16 12:45:19 +00:00
|
|
|
execute "ansible-vault encrypt --vault-id matte@vault/matte"
|
2024-06-18 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
decrypt() {
|
|
|
|
echo "${underline}Decrypting...${nounderline}"
|
2024-12-16 12:45:19 +00:00
|
|
|
execute "ansible-vault decrypt --vault-id matte@vault/matte"
|
2024-06-18 18:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
list() {
|
|
|
|
echo "${underline}Listing...${nounderline}"
|
|
|
|
i=0
|
|
|
|
for file in inventories/*/group_vars/* inventories/*/host_vars/*;
|
|
|
|
do
|
|
|
|
i=$((i + 1))
|
|
|
|
echo $i")"$file
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
execute() {
|
|
|
|
for file in inventories/*/group_vars/* inventories/*/host_vars/*;
|
|
|
|
do
|
|
|
|
i=$((i + 1))
|
|
|
|
echo $i")"$file
|
|
|
|
$1 $file
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case $action in
|
|
|
|
encrypt)
|
|
|
|
encrypt
|
|
|
|
;;
|
|
|
|
decrypt)
|
|
|
|
decrypt
|
|
|
|
;;
|
|
|
|
list)
|
|
|
|
list
|
|
|
|
;;
|
|
|
|
help)
|
|
|
|
echo "encrypt, decrypt, list"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "..."
|
|
|
|
;;
|
|
|
|
esac
|