Created
July 8, 2020 01:18
-
-
Save dialogbox/6c159ea94e53ca934c60715b041ca665 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 | |
sudo apt-get install -yqq dirmngr --install-recommends | |
echo deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/ansible.list > /dev/null | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 > /dev/null 2>&1 | |
sudo apt-get update -qq 2> /dev/null | |
sudo apt-get install -yqq ansible tmux | |
if [ -z "${TMUX}" ]; then | |
tmux new-session "/bin/bash prepare.sh" | |
exit 0 | |
fi | |
read -e -p "GCS bucket for bundle: " -i "gs://$(gcloud config get-value project)-tse-anthos-lab-bundle" GCS_BUCKET | |
gsutil stat ${GCS_BUCKET}/ansible_script_bundle.tar.gz > /dev/null | |
if [ "$?" -ne "0" ]; then | |
echo "Can not read the bundle from GCS bucket" | |
read -p "Press [Enter] key to close this window..." | |
exit 1 | |
fi | |
gsutil cp ${GCS_BUCKET}/ansible_script_bundle.tar.gz . > /dev/null | |
tar -zxvf ansible_script_bundle.tar.gz > /dev/null | |
gsutil cp -r ${GCS_BUCKET}/sa_keys . > /dev/null | |
gsutil cp ${GCS_BUCKET}/inventory.ini ./ansible > /dev/null | |
export ANSIBLE_INVENTORY=${HOME}/ansible/inventory.ini | |
cd ansible | |
ansible-playbook prepare.yml | |
cat <<EOF > ~/deploy.sh | |
#!/bin/bash | |
if [ -z "\${TMUX}" ]; then | |
tmux new-session "/bin/bash deploy.sh" | |
exit 0 | |
fi | |
read -e -p "Which type of LB are you going to use? [seesaw, f5, haproxy, manual] " -i "seesaw" LB_TYPE | |
cd ~/ansible | |
if [[ "\$LB_TYPE" == "seesaw" ]]; then | |
ansible-playbook deploy.yml --extra-vars "extra_gkectl_flags=''" -i inventory.ini | |
elif [[ "\$LB_TYPE" == "f5" ]]; then | |
ansible-playbook deploy.yml --extra-vars "extra_gkectl_flags=''" --tags f5 -i inventory.ini | |
elif [[ "\$LB_TYPE" == "haproxy" ]]; then | |
ansible-playbook deploy.yml --extra-vars "extra_gkectl_flags='--skip-validation-vips'" --tags manual -i inventory.ini | |
elif [[ "\$LB_TYPE" == "manual" ]]; then | |
ansible-playbook deploy.yml --extra-vars "extra_gkectl_flags='--skip-validation-vips'" --tags manual -i inventory.ini | |
else | |
echo "Unsupported LB type: \$LB_TYPE" | |
fi | |
read -p "Press [Enter] key to close this window..." | |
EOF | |
read -p "Press [Enter] key to close this window..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment