# Terraform & Ansible
Note: These commands/files are not being maintained by the tendermint team currently. Please use them carefully.
Automated deployments are done using Terraform (opens new window) to create servers on Digital Ocean then Ansible (opens new window) to create and manage testnets on those servers.
# Install
NOTE: see the integration bash script (opens new window) that can be run on a fresh DO droplet and will automatically spin up a 4 node testnet. The script more or less does everything described below.
- Install Terraform (opens new window) and Ansible (opens new window) on a Linux machine.
- Create a DigitalOcean API token (opens new window) with read and write capability.
- Install the python dopy package (
pip install dopy
) - Create SSH keys (
ssh-keygen
) - Set environment variables:
These will be used by both terraform
and ansible
.
# Terraform
This step will create four Digital Ocean droplets. First, go to the correct directory:
then:
and you will get a list of IP addresses that belong to your droplets.
With the droplets created and running, let's setup Ansible.
# Ansible
The playbooks in the ansible
directory (opens new window)
run ansible roles to configure the sentry node architecture. You must
switch to this directory to run ansible
(cd $GOPATH/src/github.com/tendermint/tendermint/networks/remote/ansible
).
There are several roles that are self-explanatory:
First, we configure our droplets by specifying the paths for tendermint
(BINARY
) and the node files (CONFIGDIR
). The latter expects any
number of directories named node0, node1, ...
and so on (equal to the
number of droplets created).
To create the node files run:
Then, to configure our droplets run:
Voila! All your droplets now have the tendermint
binary and required
configuration files to run a testnet.
Next, we run the install role:
which as you'll see below, executes
tendermint node --proxy_app=kvstore
on all droplets. Although we'll
soon be modifying this role and running it again, this first execution
allows us to get each node_info.id
that corresponds to each
node_info.listen_addr
. (This part will be automated in the future). In
your browser (or using curl
), for every droplet, go to IP:26657/status
and note the two just mentioned node_info
fields. Notice that blocks
aren't being created (latest_block_height
should be zero and not
increasing).
Next, open roles/install/templates/systemd.service.j2
and look for the
line ExecStart
which should look something like:
and add the --p2p.persistent_peers
flag with the relevant information
for each node. The resulting file should look something like:
Then, stop the nodes:
Finally, we run the install role again:
to re-run tendermint node
with the new flag, on all droplets. The
latest_block_hash
should now be changing and latest_block_height
increasing. Your testnet is now up and running 😃
Peek at the logs with the status role:
# Logging
The crudest way is the status role described above. You can also ship logs to Logz.io, an Elastic stack (Elastic search, Logstash and Kibana) service provider. You can set up your nodes to log there automatically. Create an account and get your API key from the notes on this page (opens new window), then:
# Cleanup
To remove your droplets, run: