Created
September 9, 2020 00:24
-
-
Save brianwhigham/e07b204e329e743be565679a55a1ee34 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
PKGS="git swift ansible" | |
PKGMGR=yum | |
REPONAME=uat-swiftstack | |
REPOOWNER=encompassdigitalmedia | |
SWIFTRC=/etc/swiftrc-uat-swiftstack | |
grep "^ID=" /etc/os-release | grep ubuntu && PKGMGR=apt | |
# set swift credentials in order to download our SSH deploy key | |
read -p "Please enter the EDMTest Swift password: " ST_KEY | |
ST_USER=EDMTest | |
ST_AUTH_INTERNET=https://us-east.mediastorage.tatamediaservices.com/auth/v1.0 | |
ST_AUTH_ATLANTA=https://atlanta.mediastorage.tatamediaservices.com/auth/v1.0 | |
ST_AUTH=$ST_AUTH_INTERNET | |
sudo cat << EOF > $SWIFTRC-atlanta | |
ST_KEY=$ST_KEY | |
ST_USER=$ST_USER | |
ST_AUTH=$ST_AUTH_ATLANTA | |
EOF | |
sudo cat << EOF > $SWIFTRC-internet | |
ST_KEY=$ST_KEY | |
ST_USER=$ST_USER | |
ST_AUTH=$ST_AUTH_INTERNET | |
EOF | |
# configure SSH to connect to github | |
sudo grep github /root/.ssh/config || { | |
sudo echo "Host github.com" >> /root/.ssh/config | |
sudo echo " User git" >> /root/.ssh/config | |
sudo echo " IdentityFile /root/.ssh/id_rsa_uat_swiftstack" >> /root/.ssh/config | |
} | |
# prepare spot for our SSH deploy key | |
sudo mkdir /root/.ssh | |
sudo chmod 700 /root/.ssh | |
# fetch the SSH deploy key from SwiftStack | |
sudo swift download -A $ST_AUTH -U $ST_USER -K "$ST_KEY" -o /root/.ssh/id_rsa_uat_swiftstack edm-conf-uat-swiftstack common/id_rsa_uat_swiftstack | |
sudo chmod 600 /root/.ssh/id_rsa_uat_swiftstack | |
# install packages | |
sudo $PKGMGR install -y $PKGS | |
# know the git host | |
sudo grep yGoK /root/.ssh/known_hosts || sudo echo "|1|yGoK0q241oj6uJ62WvVZKudX9Hc=|dwRA1ueb0u2igAdeGC0R9nj8gDU= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> /root/.ssh/known_hosts | |
# download the UAT repo | |
sudo git clone [email protected]:$REPOOWNER/$REPONAME.git /root/$REPONAME | |
# run the playbook | |
sudo ansible-playbook /root/uat-swiftstack/deploy/playbook.yaml | |
echo All done with the base configuration |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment