You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.8 KiB

  1. #!/bin/bash
  2. # This is an example set of commands that uses Terraform and Ansible to create a basecoin testnet on Digital Ocean.
  3. # Prerequisites: terraform, ansible, DigitalOcean API token, ssh-agent running with the same SSH keys added that are set up during terraform
  4. # Optional: GOPATH if you build the app yourself
  5. #export DO_API_TOKEN="<This contains the DigitalOcean API token>"
  6. #export GOPATH="<your go path>"
  7. ###
  8. # Find out TF_VAR_TESTNET_NAME (testnet name)
  9. ###
  10. if [ $# -gt 0 ]; then
  11. TF_VAR_TESTNET_NAME="$1"
  12. fi
  13. if [ -z "$TF_VAR_TESTNET_NAME" ]; then
  14. echo "Usage: $0 <TF_VAR_TESTNET_NAME>"
  15. echo "or"
  16. echo "export TF_VAR_TESTNET_NAME=<TF_VAR_TESTNET_NAME> ; $0"
  17. exit
  18. fi
  19. ###
  20. # Build Digital Ocean infrastructure
  21. ###
  22. SERVERS=2
  23. cd terraform-digitalocean
  24. terraform init
  25. terraform env new "$TF_VAR_TESTNET_NAME"
  26. #The next step copies additional terraform rules that only apply in the Tendermint network.
  27. #cp -r ../devops/terraform-tendermint/* .
  28. terraform apply -var servers=$SERVERS -var DO_API_TOKEN="$DO_API_TOKEN"
  29. cd ..
  30. ###
  31. # Build applications (optional)
  32. ###
  33. if [ -n "$GOPATH" ]; then
  34. go get -u github.com/tendermint/tendermint/cmd/tendermint
  35. go get -u github.com/tendermint/basecoin/cmd/basecoin
  36. ANSIBLE_ADDITIONAL_VARS="-e tendermint_release_install=false -e basecoin_release_intall=false"
  37. fi
  38. ###
  39. # Deploy application
  40. ###
  41. #Note that SSH Agent needs to be running with SSH keys added or ansible-playbook requires the --private-key option.
  42. cd ansible
  43. python -u inventory/digital_ocean.py --refresh-cache 1> /dev/null
  44. ansible-playbook -i inventory/digital_ocean.py install-basecoin.yml -u root -e app_options_file=ansible/app_options_files/dev_money $ANSIBLE_ADDITIONAL_VARS
  45. cd ..
  46. ###
  47. # Start application
  48. ###
  49. cd ansible
  50. ansible-playbook -i inventory/digital_ocean.py start-basecoin.yml
  51. cd ..