tendermint+basecoin configuration fixes

This commit is contained in:
Greg Szabo 2017-05-31 23:46:02 -04:00
parent 4e16ee6d78
commit 457516b194
21 changed files with 143 additions and 120 deletions

View File

@ -9,9 +9,10 @@
The playbooks in this folder run [ansible](http://www.ansible.com/) roles which: The playbooks in this folder run [ansible](http://www.ansible.com/) roles which:
* install and configure tendermint * install tendermint
* install and configure basecoin * install basecoin
* start/stop tendermint and basecoin * configure tendermint and basecoin
* start/stop tendermint and basecoin and reset their configuration
## Prerequisites ## Prerequisites
@ -27,19 +28,19 @@ Head over to the [Terraform folder](https://github.com/tendermint/tools) for a d
Optional for Amazon AWS instances: Optional for Amazon AWS instances:
* Amazon AWS API access key ID and secret access key. * Amazon AWS API access key ID and secret access key.
The cloud inventory scripts come from the ansible team at https://github.com/ansible/ansible. You can get the latest version from the contrib/inventory folder. The cloud inventory scripts come from the ansible team at their [GitHub](https://github.com/ansible/ansible) page. You can get the latest version from the contrib/inventory folder.
## Ansible setup ## Ansible setup
Ansible requires a "command machine" or "local machine" or "orchestrator machine" to run on. This can be your laptop or any machine that runs linux. (It does not have to be part of the cloud network that hosts your servers.) Ansible requires a "command machine" or "local machine" or "orchestrator machine" to run on. This can be your laptop or any machine that runs linux. (It does not have to be part of the cloud network that hosts your servers.)
Note: The below commands use the Ubuntu/Debian `apt-get` command. To make it compatible with RedHat/CentOS, replace it with `yum`. Note: All the below commands use the Ubuntu/Debian `apt-get` command. To make it compatible with RedHat/CentOS, replace it with `yum`.
``` ```
sudo apt-get install ansible sudo apt-get install ansible
``` ```
To make life easier, you can start an SSH Agent and load your SSH key(s). This way ansible will have an uninterrupted way of connecting to tour servers. To make life easier, you can start an SSH Agent and load your SSH key(s). This way ansible will have an uninterrupted way of connecting to your servers.
``` ```
ssh-agent > ~/.ssh/ssh.env ssh-agent > ~/.ssh/ssh.env
@ -84,7 +85,7 @@ AWS_SECRET_ACCESS_KEY='<The API secret access key received from Amazon>'
python -u inventory/ec2.py --refresh-cache 1> /dev/null python -u inventory/ec2.py --refresh-cache 1> /dev/null
``` ```
Note you don't need the access key and secret key set, if you are running ansible on an Amazon AMI instance with the proper IAM permissions set. Note: you don't need the access key and secret key set, if you are running ansible on an Amazon AMI instance with the proper IAM permissions set.
## Running the playbook ## Running the playbook
@ -111,7 +112,7 @@ ansible-playbook -i inventory/ec2.py install.yml
### Installing custom versions ### Installing custom versions
By default ansible installs the tendermint and basecoin binary versions defined in its [default variables](#Default variables). If you built your own version of the binaries, you can tell ansible to install that instead. By default ansible installs the tendermint and basecoin binary versions defined in its [default variables](#Default variables). If you build your own version of the binaries, you can tell ansible to install that instead.
``` ```
GOPATH="<your go path>" GOPATH="<your go path>"
@ -123,12 +124,28 @@ TF_VAR_TESTNET_NAME="testnet-servers"
ansible-playbook -i inventory/digital_ocean.py install.yml -e tendermint_release_install=false -e basecoin_release_install=false ansible-playbook -i inventory/digital_ocean.py install.yml -e tendermint_release_install=false -e basecoin_release_install=false
``` ```
## Starting the servers Alternatively you can change the variable settings in `group_vars/all`.
To be continued... ## Other commands and roles
There are few extra playbooks to make life easier managing your servers.
* install.yml - the all-in-one playbook to install and configure tendermint + basecoin
* reset.yml - stop the application, reset the configuration (blockchain), then start the application again
* stop.yml - stop the application
* start.yml - start the application
* restart.yml - restart the application
The roles are self-sufficient under the `roles/` folder.
* install-tendermint - install the tendermint application. It can install release packages or custom-compiled binaries.
* install-basecoin - install the basecoin application. It can install release packages or custom-compiled binaries.
* cleanupconfig - delete all tendermint and basecoin configuration.
* config - configure tendermint and basecoin
* stop - stop the application.
* start - start the application.
## Default variables ## Default variables
Default variables are documented under `group_vars/all`.
To be continued...

2
ansible/Vagrantfile vendored
View File

@ -14,7 +14,5 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision :ansible do |ansible| config.vm.provision :ansible do |ansible|
ansible.playbook = "install.yml" ansible.playbook = "install.yml"
ansible.verbose = 'vv'
ansible.sudo = true
end end
end end

View File

@ -1,45 +1,77 @@
--- ---
#tendermint_release_install: true ###
#tendermint_version: 0.10.0-rc1 ### Tendermint installation
#tendermint_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/tendermint/v{{tendermint_version}}/tendermint_{{tendermint_version}}_linux_amd64.zip" ###
##If tendermint_release_install == false, copy the binary from here ## This file shows and sets the global defaults for the role variables.
## tendermint_release_install indicates if the install-tendermint role should install a release version or a private build of the tendermint app
##
#tendermint_release_install: true
## tendermint_download stores the link to the specific tendermint release to install
##
#tendermint_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/tendermint/v0.10.0-rc1/tendermint_0.10.0-rc1_linux_amd64.zip"
## tendermint_binary stores the path to a private tendermint binary to install
##
#tendermint_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/tendermint" #tendermint_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/tendermint"
## Details of the linux user the tendermint app uses
##
#tendermint_user: tendermint #tendermint_user: tendermint
#tendermint_group: tendermint #tendermint_group: tendermint
## Upstart start/stop conditions can vary by distribution and environment
#tendermint_upstart_start_on: start on runlevel [345]
#tendermint_upstart_stop_on: stop on runlevel [!345]
#tendermint_home: /var/lib/tendermint #tendermint_home: /var/lib/tendermint
## tendermint_log_file stores the path to the tendermint application log
##
#tendermint_log_file: /var/log/tendermint.log #tendermint_log_file: /var/log/tendermint.log
#basecoin_release_install: true ###
#basecoin_version: 0.4.0 ### Basecoin installation
#basecoin_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/basecoin/v{{basecoin_version}}/basecoin_{{basecoin_version}}_linux_amd64.zip" ###
##If basecoin_release_install == false, copy the binary from here ## basecoin_release_install indicates if the install-basecoin role should install a release version or a private build of the basecoin app
##
#basecoin_release_install: true
## basecoin_download stores the link to the specific basecoin release to install
##
#basecoin_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/basecoin/v0.4.0/basecoin_0.4.0_linux_amd64.zip"
## basecoin_binary stores the path to a private basecoin binary to install
##
#basecoin_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/basecoin" #basecoin_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/basecoin"
## Details of the linux user the basecoin app uses
##
#basecoin_user: basecoin #basecoin_user: basecoin
#basecoin_group: basecoin #basecoin_group: basecoin
## Upstart start/stop conditions can vary by distribution and environment
#basecoin_upstart_start_on: start on runlevel [345]
#basecoin_upstart_stop_on: stop on runlevel [!345]
#basecoin_home: /var/lib/basecoin #basecoin_home: /var/lib/basecoin
## basecoin_log_file stores the path to the basecoin application log
##
#basecoin_log_file: /var/log/basecoin.log #basecoin_log_file: /var/log/basecoin.log
###
### Basecoin configuration
###
## basecoin_inprocess indicates if basecoin should run tendermint in-process
##
#basecoin_inprocess: false #basecoin_inprocess: false
#Used by the config role ###
#testnet_name: test-chain ### Development settings
###
## Used by the config role to find seed IPs and public keys and set the chain_id in genesis.json and config.toml
##
#testnet_name: testnet1
basecoin_inprocess: false ## Used by the config role to add a lot of mycoins to wallet 0x1B1BE55F969F54064628A63B9559E7C21C925165.
tendermint_release_install: false ## Use /usr/share/basecoin/dev-keys/key.json to access them.
basecoin_release_install: false ## Tendermint data has to be cleared when setting or resetting this key.
##
#dev_money: false

View File

@ -1,8 +0,0 @@
---
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
user: root
roles:
- cleanupconfig
- { role: config, testnet_name: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" }

View File

@ -4,6 +4,6 @@
user: root user: root
roles: roles:
- stop - stop
- cleanupconfig - { role: cleanupconfig, when: not reconfig|default(false)|bool }
- { role: config, testnet_name: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" } - { role: config, testnet_name: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" }
- start - start

View File

@ -8,5 +8,5 @@ basecoin_group: basecoin
basecoin_home: /var/lib/basecoin basecoin_home: /var/lib/basecoin
basecoin_inprocess: false basecoin_inprocess: false
testnet_name: test-chain testnet_name: testnet1
dev_money: false

View File

@ -22,11 +22,10 @@
- name: register basecoin public keys as host facts - name: register basecoin public keys as host facts
when: basecoin_inprocess|bool when: basecoin_inprocess|bool
set_fact: "basecoin_pubkey={{basecoinpubkeys.stdout_lines[0]}}" set_fact: "pubkey={{basecoinpubkeys.stdout_lines[0]}}"
connection: local connection: local
- name: copy basecoin genesis.json - genesis_time will be updated - name: copy basecoin genesis.json - genesis_time will be updated
when: basecoin_inprocess|bool
template: template:
src: genesis-basecoin.json.j2 src: genesis-basecoin.json.j2
dest: "{{basecoin_home}}/.basecoin/genesis.json" dest: "{{basecoin_home}}/.basecoin/genesis.json"

View File

@ -19,7 +19,7 @@
changed_when: false changed_when: false
- name: register tendermint public keys as host facts - name: register tendermint public keys as host facts
set_fact: "tendermint_pubkey={{tendermintpubkeys.stdout_lines[0]}}" set_fact: "pubkey={{tendermintpubkeys.stdout_lines[0]}}"
connection: local connection: local
- name: copy tendermint genesis.json - genesis_time will be updated - name: copy tendermint genesis.json - genesis_time will be updated

View File

@ -8,7 +8,7 @@ db_backend = "leveldb"
log_level = "debug" log_level = "debug"
[rpc] [rpc]
laddr = "tcp://{{ do_private_ip | default('0.0.0.0') }}:46657" laddr = "tcp://127.0.0.1:46657"
[p2p] [p2p]
laddr = "tcp://{{inventory_hostname}}:46656" laddr = "tcp://{{inventory_hostname}}:46656"

View File

@ -1,4 +1,23 @@
{ {
"genesis_time":"{{ansible_date_time.iso8601}}",
"chain_id":"{{testnet_name}}",
{% if basecoin_inprocess|bool %}
"validators":
[
{% set comma = joiner(",") %}
{% for host in groups[testnet_name] %}
{{ comma() }}
{
"pub_key":{"type":"ed25519","data":{{hostvars[host]["pubkey"]}}},
"amount":10,
"name":"{{hostvars[host]["ansible_hostname"]}}"
}
{% endfor %}
],
{% endif %}
"app_hash":""
{% if dev_money|bool %}
,
"app_options": { "app_options": {
"accounts": [{ "accounts": [{
"pub_key": { "pub_key": {
@ -12,21 +31,7 @@
} }
] ]
}] }]
},
"genesis_time":"{{ansible_date_time.iso8601_micro}}",
"chain_id":"{{testnet_name}}",
"validators":
[
{% set comma = joiner(",") %}
{% for host in groups[testnet_name] %}
{{ comma() }}
{
"pub_key":{"type":"ed25519","data":{{hostvars[host]["basecoin_pubkey"]}}},
"amount":10,
"name":"{{hostvars[host]["ansible_hostname"]}}"
} }
{% endfor %} {% endif %}
],
"app_hash":""
} }

View File

@ -1,18 +1,4 @@
{ {
"app_options": {
"accounts": [{
"pub_key": {
"type": "ed25519",
"data": "619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279"
},
"coins": [
{
"denom": "mycoin",
"amount": 9007199254740992
}
]
}]
},
"genesis_time":"{{ansible_date_time.iso8601}}", "genesis_time":"{{ansible_date_time.iso8601}}",
"chain_id":"{{testnet_name}}", "chain_id":"{{testnet_name}}",
"validators": "validators":
@ -21,7 +7,7 @@
{% for host in groups[testnet_name] %} {% for host in groups[testnet_name] %}
{{ comma() }} {{ comma() }}
{ {
"pub_key":{"type":"ed25519","data":{{hostvars[host]["tendermint_pubkey"]}}}, "pub_key":{"type":"ed25519","data":{{hostvars[host]["pubkey"]}}},
"amount":10, "amount":10,
"name":"{{hostvars[host]["ansible_hostname"]}}" "name":"{{hostvars[host]["ansible_hostname"]}}"
} }

View File

@ -1,18 +1,12 @@
--- ---
basecoin_release_install: true basecoin_release_install: true
basecoin_version: 0.4.0 basecoin_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/basecoin/v0.4.0/basecoin_0.4.0_linux_amd64.zip"
basecoin_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/basecoin/v{{basecoin_version}}/basecoin_{{basecoin_version}}_linux_amd64.zip"
#If basecoin_release_install == false, copy the binary from here
basecoin_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/basecoin" basecoin_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/basecoin"
basecoin_user: basecoin basecoin_user: basecoin
basecoin_group: basecoin basecoin_group: basecoin
# Upstart start/stop conditions can vary by distribution and environment
basecoin_upstart_start_on: start on runlevel [345]
basecoin_upstart_stop_on: stop on runlevel [!345]
basecoin_home: /var/lib/basecoin basecoin_home: /var/lib/basecoin
basecoin_log_file: /var/log/basecoin.log basecoin_log_file: /var/log/basecoin.log

View File

@ -104,10 +104,10 @@
- reload systemd - reload systemd
- name: Create example folder - name: Create example folder
file: path=/usr/share/basecoin/example-keys state=directory file: path=/usr/share/basecoin/dev-keys state=directory
- name: Copy example keys - name: Copy example keys
copy: "src={{item}} dest=/usr/share/basecoin/example-keys/{{item}}" copy: "src={{item}} dest=/usr/share/basecoin/dev-keys/{{item}}"
with_items: with_items:
- key.json - key.json
- key2.json - key2.json

View File

@ -1,8 +1,8 @@
# Basecoin (Upstart unit) # Basecoin (Upstart unit)
description "Basecoin" description "Basecoin"
start on {{ basecoin_upstart_start_on }} start on runlevel [2345]
stop on {{ basecoin_upstart_stop_on }} stop on runlevel [!2345]
script script
# Use su to become tendermint user non-interactively on old Upstart versions (see http://superuser.com/a/234541/76168) # Use su to become tendermint user non-interactively on old Upstart versions (see http://superuser.com/a/234541/76168)

View File

@ -1,18 +1,14 @@
--- ---
tendermint_release_install: true tendermint_release_install: true
tendermint_version: 0.10.0-rc1 tendermint_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/tendermint/v0.10.0-rc1/tendermint_0.10.0-rc1_linux_amd64.zip"
tendermint_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/tendermint/v{{tendermint_version}}/tendermint_{{tendermint_version}}_linux_amd64.zip"
#If tendermint_release_install == false, copy the binary from here
tendermint_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/tendermint" tendermint_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/tendermint"
tendermint_user: tendermint tendermint_user: tendermint
tendermint_group: tendermint tendermint_group: tendermint
# Upstart start/stop conditions can vary by distribution and environment
tendermint_upstart_start_on: start on runlevel [345]
tendermint_upstart_stop_on: stop on runlevel [!345]
tendermint_home: /var/lib/tendermint tendermint_home: /var/lib/tendermint
tendermint_log_file: /var/log/tendermint.log tendermint_log_file: /var/log/tendermint.log
basecoin_inprocess: false

View File

@ -1,8 +1,8 @@
# Tendermint (Upstart unit) # Tendermint (Upstart unit)
description "Tendermint" description "Tendermint"
start on {{ tendermint_upstart_start_on }} {{basecoin_inprocess|bool | ternary('','start on (runlevel [2345] and started basecoin)')}}
stop on {{ tendermint_upstart_stop_on }} {{basecoin_inprocess|bool | ternary('','stop on (runlevel [!2345] and stopping basecoin)')}}
script script
# Use su to become tendermint user non-interactively on old Upstart versions (see http://superuser.com/a/234541/76168) # Use su to become tendermint user non-interactively on old Upstart versions (see http://superuser.com/a/234541/76168)

View File

@ -1,6 +1,6 @@
[Unit] [Unit]
Description=Tendermint Description=Tendermint
Requires=network-online.target Requires=network-online.target{{basecoin_inprocess|bool | ternary('',' basecoin.target')}}
After=network-online.target After=network-online.target
[Service] [Service]

View File

@ -1,7 +1,7 @@
--- ---
- name: stop tendermint - name: stop tendermint
when: not basecoin_inprocess|bool #when: not basecoin_inprocess|bool
service: name=tendermint state=stopped service: name=tendermint state=stopped
- name: stop basecoin - name: stop basecoin

View File

@ -23,3 +23,9 @@ resource "digitalocean_droplet" "cluster" {
} }
#resource "digitalocean_floating_ip" "cluster" {
# droplet_id = "${element(digitalocean_droplet.cluster.*.id,count.index)}"
# region = "${element(digitalocean_droplet.cluster.*.region,count.index)}"
# count = "${var.servers}"
#}

View File

@ -1,19 +1,25 @@
// The cluster name, e.g cdn // The cluster name
output "name" { output "name" {
value = "${var.name}" value = "${var.name}"
} }
// The list of cluster instance ids // The list of cluster instance IDs
output "instances" { output "instances" {
value = ["${digitalocean_droplet.cluster.*.id}"] value = ["${digitalocean_droplet.cluster.*.id}"]
} }
// The list of cluster instance ips // The list of cluster instance private IPs
output "private_ips" { output "private_ips" {
value = ["${digitalocean_droplet.cluster.*.ipv4_address_private}"] value = ["${digitalocean_droplet.cluster.*.ipv4_address_private}"]
} }
// The list of cluster instance ips // The list of cluster instance public IPs
output "public_ips" { output "public_ips" {
value = ["${digitalocean_droplet.cluster.*.ipv4_address}"] value = ["${digitalocean_droplet.cluster.*.ipv4_address}"]
} }
#// The list of cluster floating IPs
#output "floating_ips" {
# value = ["${digitalocean_floating_ip.cluster.*.ip_address}"]
#}

View File

@ -37,15 +37,7 @@ output "public_ips" {
value = "${module.cluster.public_ips}" value = "${module.cluster.public_ips}"
} }
output "private_ips" { #output "floating_ips" {
value = "${join(",",module.cluster.private_ips)}" # value = "${module.cluster.floating_ips}"
} #}
output "seeds" {
value = "${join(":46656,",module.cluster.public_ips)}:46656"
}
output "rpcs" {
value = "${join(":46657,",module.cluster.public_ips)}:46657"
}