31/03/21 Notes
Vultr Instance Provisioning Tool
#!/bin/bash
vultr_function () {
echo "Welcome to the Vultr Instance Provisioning Tool."
while true; do
echo "Enter 0 to install the vultr-cli tool."
echo "Enter 1 to delete an existing instance."
echo "Enter 2 to list available geographic regions."
echo "Enter 3 to list available compute plans."
echo "Enter 4 to list available Operating Systems."
echo "Enter 5 to list available Boot Scripts."
echo "Enter 6 to create an Ansible Client."
echo "Enter 7 to create an Ansible Server."
echo "Enter 8 to create a Puppet Agent."
echo "Enter 9 to create a Puppet Master."
echo "Enter exit to end program."
read selection
case $selection in
0) wget https://github.com/vultr/vultr-cli/releases/download/v2.3.0/vultr-cli_2.3.0_linux_64-bit.tar.gz
tar -xvf vultr-cli_2.3.0_linux_64-bit.tar.gz
;;
1) echo "Current instances:"
./vultr-cli instance list
echo "Enter instance ID to delete instance"
read VMDEL
echo "Are you sure you want to delete $VMDEL? (y/n)"
read CHOICE
if [ $CHOICE == 'y' -o $CHOICE == 'Y' ]; then
./vultr-cli instance delete $VMDEL
elif [ $CHOICE == 'n' -o $CHOICE == 'N' ]; then
echo "Returning to menu."
else
echo "You entered $CHOICE. You must enter y or n."
fi
;;
2) ./vultr-cli regions list
;;
3) ./vultr-cli plans list
;;
4) ./vultr-cli os list
;;
5) ./vultr-cli script list
;;
6) echo "Enter Ansible Client instance name."
read VMADD
./vultr-cli instance create --region syd --plan vc2-1c-1gb --os 401 --label $VMADD --ipv6 false --script-id c65f6200-2729-43c9-b7ae-f8331262ba6c
;;
7) echo "Enter Ansible Server instance name."
read VMADD
./vultr-cli instance create --region syd --plan vc2-1c-1gb --os 401 --label $VMADD --ipv6 false --script-id 2b9cd64c-c7f7-41fd-9678-5a5786e9d646
;;
8) echo "Enter Puppet Agent instance name."
read VMADD
./vultr-cli instance create --region syd --plan vc2-1c-1gb --os 401 --label $VMADD --ipv6 false --script-id c0fd5aca-8a17-49d7-aff0-10104b125111
;;
9) echo "Enter Puppet Server instance name."
read VMADD
./vultr-cli instance create --region syd --plan vc2-2c-4gb --os 401 --label $VMADD --ipv6 false --script-id cab78847-2639-4e60-853e-ab9e7eaad1ba
;;
exit) break
;;
*) echo "Invalid response"
;;
esac
done
}
vultr_function