Created
September 9, 2020 00:36
-
-
Save brianwhigham/973c3c73f82f16110aeff58bac9c731a 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 | |
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 UFFAaQ /root/.ssh/known_hosts || sudo ssh-keyscan -H github.com >> /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