Difference between revisions of "Az cli bash wrapper"
Jump to navigation
Jump to search
(Created page with "#!/usr/bin/env bash # Utility script example. Adjust as needed set -eu count=3 # env=d env=p if [ $env == "d" ]; then rgEnv=D elif [ $env == "p" ]; then rgEnv=P else ech...") |
|||
Line 1: | Line 1: | ||
+ | ``` | ||
#!/usr/bin/env bash | #!/usr/bin/env bash | ||
# Utility script example. Adjust as needed | # Utility script example. Adjust as needed | ||
Line 37: | Line 38: | ||
runCmd "zpool status" | runCmd "zpool status" | ||
done | done | ||
+ | ``` |
Latest revision as of 17:31, 13 May 2022
#!/usr/bin/env bash # Utility script example. Adjust as needed set -eu count=3 # env=d env=p if [ $env == "d" ]; then rgEnv=D elif [ $env == "p" ]; then rgEnv=P else echo "Unsupported environment. Options: d p" exit 1 fi rgName=g1-$rgEnv runCmd(){ cmd=$1 az vm run-command invoke --resource-group $rgName --name $vmName --command-id RunShellScript --scripts "$cmd" } runScript(){ script=$1 az vm run-command invoke --resource-group $rgName --name $vmName --command-id RunShellScript --scripts @$script } for i in $(seq $count); do diskName="az${env}${i}-k8s_mdisk1-plrs" vmName=az${env}${i}-k8s echo Adding disk to zfs on vm $vmName in $rgName diskId=$(az disk show -g $rgName -n $diskName --query 'id' -o tsv) echo Attaching disk $diskId to vm $vmName in $rgName az vm disk attach -g $rgName --vm-name $vmName --name $diskId || true runScript prepZfs.sh runCmd "zpool status" done