deploy-single-node.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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-single-node.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.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-single-node-playbook.yml \
  36. --extra-vars "binary_file=$BINARY_FILE chain_spec_file=$CHAIN_SPEC_FILE"
  37. fi