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.

57 lines
1.6 KiB

  1. #!/bin/bash
  2. # This is an example set of commands that uses Terraform and Ansible to create a 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. terraform apply -var servers=$SERVERS -var DO_API_TOKEN="$DO_API_TOKEN"
  27. cd ..
  28. ###
  29. # Build applications (optional)
  30. ###
  31. if [ -n "$GOPATH" ]; then
  32. go get -u github.com/tendermint/tendermint/cmd/tendermint
  33. go get -u github.com/tendermint/basecoin/cmd/basecoin
  34. ANSIBLE_ADDITIONAL_VARS="-e tendermint_release_install=false -e basecoin_release_intall=false"
  35. fi
  36. ###
  37. # Deploy application
  38. ###
  39. #Note that SSH Agent needs to be running with SSH keys added or ansible-playbook requires the --private-key option.
  40. cd ansible
  41. python -u inventory/digital_ocean.py --refresh-cache 1> /dev/null
  42. ansible-playbook -i inventory/digital_ocean.py install.yml $ANSIBLE_ADDITIONAL_VARS
  43. cd ..
  44. ###
  45. # Start application
  46. ###
  47. cd ansible
  48. ansible-playbook -i inventory/digital_ocean.py start.yml
  49. cd ..