deploy-playground.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. set -e
  3. source common.sh
  4. if [ -z "$1" ]; then
  5. echo "ERROR: Configuration file not passed"
  6. echo "Please use ./deploy-playground.sh PATH/TO/CONFIG to run this script"
  7. exit 1
  8. else
  9. echo "Using $1 file for config"
  10. source $1
  11. fi
  12. if [ ! -f "$KEY_PATH" ]; then
  13. echo "Key file not found at $KEY_PATH"
  14. exit 1
  15. fi
  16. # Deploy the CloudFormation template
  17. echo -e "\n\n=========== Deploying single node ==========="
  18. aws cloudformation deploy \
  19. --region $REGION \
  20. --profile $CLI_PROFILE \
  21. --stack-name $SINGLE_NODE_STACK_NAME \
  22. --template-file cloudformation/single-instance-docker.yml \
  23. --no-fail-on-empty-changeset \
  24. --capabilities CAPABILITY_NAMED_IAM \
  25. --parameter-overrides \
  26. EC2InstanceType=$DEFAULT_EC2_INSTANCE_TYPE \
  27. KeyName=$AWS_KEY_PAIR_NAME
  28. # If the deploy succeeded, get the IP and configure the created instance
  29. if [ $? -eq 0 ]; then
  30. # Install additional Ansible roles from requirements
  31. ansible-galaxy install -r requirements.yml
  32. SERVER_IP=$(get_aws_export $SINGLE_NODE_STACK_NAME "PublicIp")
  33. echo -e "New Node Public IP: $SERVER_IP"
  34. echo -e "\n\n=========== Configuring node ==========="
  35. ansible-playbook -i $SERVER_IP, --private-key $KEY_PATH deploy-playground-playbook.yml \
  36. --extra-vars "branch_name=$BRANCH_NAME git_repo=$GIT_REPO skip_chain_setup=$SKIP_CHAIN_SETUP
  37. stack_name=$SINGLE_NODE_STACK_NAME runtime_profile=$RUNTIME_PROFILE"
  38. fi