deploy-single-node.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 [ $ACCOUNT_ID == None ]; then
  13. echo "Couldn't find Account ID, please check if AWS Profile $CLI_PROFILE is set"
  14. exit 1
  15. fi
  16. if [ ! -f "$KEY_PATH" ]; then
  17. echo "Key file not found at $KEY_PATH"
  18. exit 1
  19. fi
  20. # # Deploy the CloudFormation template
  21. echo -e "\n\n=========== Deploying single node ==========="
  22. aws cloudformation deploy \
  23. --region $REGION \
  24. --profile $CLI_PROFILE \
  25. --stack-name $SINGLE_NODE_STACK_NAME \
  26. --template-file single-instance.yml \
  27. --no-fail-on-empty-changeset \
  28. --capabilities CAPABILITY_NAMED_IAM \
  29. --parameter-overrides \
  30. EC2InstanceType=$DEFAULT_EC2_INSTANCE_TYPE \
  31. KeyName=$AWS_KEY_PAIR_NAME
  32. # If the deploy succeeded, get the IP and configure the created instance
  33. if [ $? -eq 0 ]; then
  34. # Install additional Ansible roles from requirements
  35. ansible-galaxy install -r requirements.yml
  36. SERVER_IP=$(get_aws_export $SINGLE_NODE_STACK_NAME "PublicIp")
  37. echo -e "New Node Public IP: $SERVER_IP"
  38. echo -e "\n\n=========== Configuring node ==========="
  39. ansible-playbook -i $SERVER_IP, --private-key $KEY_PATH single-node-playbook.yml \
  40. --extra-vars "binary_file=$BINARY_FILE chain_spec_file=$CHAIN_SPEC_FILE"
  41. fi