Created
November 22, 2024 16:49
-
-
Save goors/cd1df6914b55de50dade8425033d628a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while getopts ":v:" opt; do | |
case ${opt} in | |
v ) | |
vault_name=$OPTARG | |
;; | |
\? ) | |
echo "Invalid option: $OPTARG" 1>&2 | |
exit 1 | |
;; | |
: ) | |
echo "Invalid option: $OPTARG requires an argument" 1>&2 | |
exit 1 | |
;; | |
esac | |
done | |
# Verify that all required options are provided | |
if [[ -z $vault_name ]]; then | |
echo "Usage: $0 -v <vault_name>" >&2 | |
exit 1 | |
fi | |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | |
password=$(grep -oP 'The generated password for the elastic built-in superuser is : \K\S+' /var/log/cloud-init-output.log) | |
secret_name="elastic-superuser-password" | |
secret_value="$password" | |
az keyvault secret set --vault-name "$vault_name" --name "$secret_name" --value "$secret_value" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment