deploy-single-node.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. set -e
  3. if [ -z "$1" ]; then
  4. echo "ERROR: Configuration file not passed"
  5. echo "Please use ./deploy-infra.sh PATH/TO/CONFIG to run this script"
  6. exit 1
  7. else
  8. echo "Using $1 file for config"
  9. source $1
  10. fi
  11. if [ $ACCOUNT_ID == None ]; then
  12. echo "Couldn't find Account ID, please check if AWS Profile $CLI_PROFILE is set"
  13. exit 1
  14. fi
  15. if [ ! -f "$KEY_PATH" ]; then
  16. echo "Key file not found at $KEY_PATH"
  17. exit 1
  18. fi
  19. # # Deploy the CloudFormation template
  20. echo -e "\n\n=========== Deploying single instance ==========="
  21. aws cloudformation deploy \
  22. --region $REGION \
  23. --profile $CLI_PROFILE \
  24. --stack-name $SINGLE_NODE_STACK_NAME \
  25. --template-file single-instance.yml \
  26. --no-fail-on-empty-changeset \
  27. --capabilities CAPABILITY_NAMED_IAM \
  28. --parameter-overrides \
  29. EC2InstanceType=$DEFAULT_EC2_INSTANCE_TYPE \
  30. KeyName=$AWS_KEY_PAIR_NAME \
  31. EC2AMI=$EC2_AMI_ID
  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 "PublicIp")
  37. echo -e "New Node Public IP: $SERVER_IP"
  38. echo -e "\n\n=========== Configuring the chain spec file and Pioneer app ==========="
  39. ansible-playbook -i $SERVER_IP, --private-key $KEY_PATH new-node-playbook.yml \
  40. --extra-vars "binary_file=$BINARY_FILE chain_spec_file=$CHAIN_SPEC_FILE"
  41. fi