Ansible refactor: uses package repositories. Added option to separately update service/tendermint genesis.json

This commit is contained in:
Greg Szabo
2017-06-18 01:57:07 +00:00
parent c996b13dae
commit 7239e41c4a
55 changed files with 333 additions and 720 deletions
+14 -26
View File
@@ -1,18 +1,15 @@
# Ansible playbook for Tendermint
# Ansible playbook for Tendermint applications
![Ansible plus Tendermint](img/a_plus_t.png)
* [Prerequisites](#Prerequisites)
* [Ansible setup](#Ansible setup)
* [Running the playbook](#Running the playbook)
* [Example playbook that configures a Tendermint on Ubuntu](#example-playbook-that-configures-a-tendermint-on-ubuntu)
The playbooks in this folder run [ansible](http://www.ansible.com/) roles which:
* install tendermint
* install basecoin
* configure tendermint and basecoin
* start/stop tendermint and basecoin and reset their configuration
* install and configure basecoin or ethermint
* start/stop basecoin or ethermint and reset their configuration
## Prerequisites
@@ -23,7 +20,7 @@ Optional for DigitalOcean droplets:
* DigitalOcean API Token
* python dopy package
Head over to the [Terraform folder](https://github.com/tendermint/tools) for a description on how to get a DigitalOcean API Token.
Head over to the [Terraform folder](https://github.com/tendermint/tools/tree/master/terraform-digitalocean) for a description on how to get a DigitalOcean API Token.
Optional for Amazon AWS instances:
* Amazon AWS API access key ID and secret access key.
@@ -32,7 +29,7 @@ The cloud inventory scripts come from the ansible team at their [GitHub](https:/
## 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 can run ansible. (It does not have to be part of the cloud network that hosts your servers.)
Use the official [Ansible installation guide](http://docs.ansible.com/ansible/intro_installation.html) to install Ansible. Here are a few examples on basic installation commands:
@@ -135,13 +132,13 @@ If the playbook cannot connect to the servers because of public key denial, your
If you need to connect to the nodes as root but your local username is different, use the ansible option `-u root` to tell ansible to connect to the servers and authenticate as the root user.
If you secured your server and you need to `sudo` for root access, use the the `-b` or `--become` option to tell ansible to sudo to root after connecting to the server. In the Terraform-DigitalOcean example, if you created the ec2-user (or if you are simply on Amazon AWS), you need to add the options `-u ec2-user -b` to ansible to tell it to connect as the ec2-user and then sudo to root to run the playbook.
If you secured your server and you need to `sudo` for root access, use the the `-b` or `--become` option to tell ansible to sudo to root after connecting to the server. In the Terraform-DigitalOcean example, if you created the ec2-user by adding the `noroot=true` option (or if you are simply on Amazon AWS), you need to add the options `-u ec2-user -b` to ansible to tell it to connect as the ec2-user and then sudo to root to run the playbook.
### DigitalOcean
```
DO_API_TOKEN="<The API token received from DigitalOcean>"
TF_VAR_TESTNET_NAME="testnet-servers"
ansible-playbook -i inventory/digital_ocean.py install-basecoin.yml
ansible-playbook -i inventory/digital_ocean.py install.yml -e service=basecoin
```
### Amazon AWS
@@ -149,22 +146,20 @@ ansible-playbook -i inventory/digital_ocean.py install-basecoin.yml
AWS_ACCESS_KEY_ID='<The API access key ID received from Amazon>'
AWS_SECRET_ACCESS_KEY='<The API secret access key received from Amazon>'
TF_VAR_TESTNET_NAME="testnet-servers"
ansible-playbook -i inventory/ec2.py install-basecoin.yml
ansible-playbook -i inventory/ec2.py install.yml -e service=basecoin
```
### Installing custom versions
By default ansible installs the tendermint, basecoin or ethermint 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.
By default ansible installs the tendermint, basecoin or ethermint binary versions from the latest release in the repository. If you build your own version of the binaries, you can tell ansible to install that instead.
```
GOPATH="<your go path>"
go get -u github.com/tendermint/tendermint/cmd/tendermint
go get -u github.com/tendermint/basecoin/cmd/basecoin
go get -u github.com/tendermint/ethermint/cmd/basecoin
DO_API_TOKEN="<The API token received from DigitalOcean>"
TF_VAR_TESTNET_NAME="testnet-servers"
ansible-playbook -i inventory/digital_ocean.py install-basecoin.yml -e tendermint_release_install=false -e basecoin_release_install=false
ansible-playbook -i inventory/digital_ocean.py install.yml -e service=basecoin -e release_install=false
```
Alternatively you can change the variable settings in `group_vars/all`.
@@ -173,25 +168,18 @@ Alternatively you can change the variable settings in `group_vars/all`.
There are few extra playbooks to make life easier managing your servers.
* install-tendermint-core.yml - Only install the tendermint application. This is only useful if you are developing your own ABCI.
* install-basecoin.yml - Install tendermint and basecoin applications.
* install-ethermint.yml - Install tendermint and ethermint applications.
* install.yml - Install basecoin or ethermint applications. (Tendermint gets installed automatically.) Use the `service` parameter to define which application to install. Defaults to `basecoin`.
* reset.yml - Stop the application, reset the configuration and data, then start the application again. You need to pass `-e service=<servicename>`, like `-e service=basecoin`. It will restart the underlying tendermint application too.
* restart.yml - Restart a service on all nodes. You need to pass `-e service=<servicename>`, like `-e service=basecoin`. It will restart the underlying tendermint application too.
* stop.yml - Stop the application. You need to pass `-e service=<servicename>`.
* start.yml - Start the application. You need to pass `-e service=<servicename>`.
* stop-basecoin.yml - Stop the basecoin and tendermint applications.
* start-basecoin.yml - Start the basecoin and tendermint applications.
* stop-ethermint.yml - Stop the ethermint and tendermint applications.
* start-ethermint.yml - Start the ethermint and tendermint applications.
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.
* install-ethermint - install the ethermint application. It can install release packages or custom-compiled binaries.
* cleanupdata - delete tendermint database.
* config - configure the tendermint application
* install - install the application defined in the `service` parameter. It can install release packages and update them with custom-compiled binaries.
* rmdb - delete the tendermint database for a service.
* config - configure the application defined in `service`. It also configures the underlying tendermint service. Check `group_vars/all` for options.
* stop - stop an application. Requires the `service` parameter set.
* start - start an application. Requires the `service` parameter set.
-6
View File
@@ -1,6 +0,0 @@
---
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- { role: config, testnet_name: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" }
+16
View File
@@ -0,0 +1,16 @@
# This is a TOML config file.
# For more information, see https://github.com/toml-lang/toml
proxy_app = "tcp://127.0.0.1:46658"
moniker = "146.185.178.252"
fast_sync = true
db_backend = "leveldb"
log_level = "debug"
[rpc]
laddr = "tcp://0.0.0.0:46657"
[p2p]
laddr = "tcp://0.0.0.0:46656"
seeds = "138.197.154.40:46656,138.68.244.161:46656,128.199.192.199:46656,46.101.41.147:46656,162.243.247.32:46656,207.154.231.86:46656"
+153
View File
@@ -0,0 +1,153 @@
{
"genesis_time":"2017-06-10T03:24:06Z",
"chain_id":"ball-n-chain",
"validators":
[
{
"pub_key":{"type":"ed25519","data":"3D73A11D01B03F8A54694A2291B878123F25C7BFAD6B187ECF0CA059CB6F73C2"},
"amount":10,
"name":"ball-n-chain-node0"
}
,
{
"pub_key":{"type":"ed25519","data":"5DD43295A0E05872A0CA80CA37D785FED64AF1F2140EB68C111BD114751B4EDB"},
"amount":10,
"name":"ball-n-chain-node6"
}
,
{
"pub_key":{"type":"ed25519","data":"BDFEE13230E60EB2E3026C8DC158CC0AE29C857507C2B95EC2486B946ECDE6BF"},
"amount":10,
"name":"ball-n-chain-node4"
}
,
{
"pub_key":{"type":"ed25519","data":"01763737DA0B4C09166DE5496F380665EEF85CDB747F143840BF7E0D1939489F"},
"amount":10,
"name":"ball-n-chain-node5"
}
,
{
"pub_key":{"type":"ed25519","data":"F40236D218C48DA6EF02BA42D4978F4F7FBE62D068E733CCDE9446B42004A866"},
"amount":10,
"name":"ball-n-chain-node2"
}
,
{
"pub_key":{"type":"ed25519","data":"93E0A170ADF8D0E6F94AA3C55A076A1574086EADFD7A19EA59911B043F1CE614"},
"amount":10,
"name":"ball-n-chain-node3"
}
,
{
"pub_key":{"type":"ed25519","data":"3DE45E9B5BAF01F172E9C72C9876CFAB49AD6823320D0769868C12045E572C6B"},
"amount":10,
"name":"ball-n-chain-node1"
}
],
"app_hash":"",
"app_options": {
"accounts": [
{
"name": "anton",
"address": "40CC622438D3E42148A1FFD3A27C07C100F8FA3D",
"pub_key": {
"type": "ed25519",
"data": "97BD389257763747488803DC686A8819C685936A3CD275D54EABEE51E0117EE6"
},
"coins": [
{
"denom": "anton",
"amount": 9007199254740992
},
{
"denom": "tank",
"amount": 99
}
]
},
{
"name": "adrian",
"address": "98F28277FA8C512968BBDE443F5DB27AC743F814",
"pub_key": {
"type": "ed25519",
"data": "2E7EAB9E4C93D3657A63E063D6ABB851596BA97ED9F4EB9A2FC714043DC9685D"
},
"coins": [
{
"denom": "axi",
"amount": 1928936473812
},
{
"denom": "bear",
"amount": 42
}
]
},
{
"name": "bucky",
"address": "2B24DEE2364762300168DF19B6C18BCE2D399EA2",
"pub_key": {
"type": "ed25519",
"data": "37BF9D6F8D66DC3FAECD330291CF08DF52E2F646B01F7E43BC0A746AED927A62"
},
"coins": [
{
"denom": "buckyball",
"amount": 20000000000
},
{
"denom": "bumblebee",
"amount": 100
},
{
"denom": "french",
"amount": 10
},
{
"denom": "frey",
"amount": 4838271727204
}
]
},
{
"name": "phomer",
"address": "BAA67E0346AF48A05330149A3A72D9B974E9EBD2",
"pub_key": {
"type": "ed25519",
"data": "F5DF27FD625800D971A9E9B2607F0052480E49A12BE85E17336F773FE6FB9BC9"
},
"coins": [
{
"denom": "antipho",
"amount": 33
},
{
"denom": "pho",
"amount": 8367251830291
}
]
},
{
"name": "shadow",
"address": "B140EFAAE6D5CA1C8E98814C557AF7112E3B9EAE",
"pub_key": {
"type": "ed25519",
"data": "F492282705DF29ACC3BB803D543B7BF98C8080FA28AE85B62B45827EA9DA8167"
},
"coins": [
{
"denom": "shadow",
"amount": 53712836452781
},
{
"denom": "unit",
"amount": 1
}
]
}
]
}
}
+20 -49
View File
@@ -5,66 +5,37 @@
## 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
## install
##
## 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/tendermint_0.10.0_linux_amd64.zip"
## service variable defines which service is going to be managed. It can be set to basecoin or ethermint.
service: basecoin
## tendermint_binary stores the path to a private tendermint binary to install
##
#tendermint_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/tendermint"
## release_install indicates if the install role should look for a privately built binary after installing the service package. If set to false, the privately built binary in the GOPATH is going to override the binary on the target systems.
#release_install: true
## Details of the linux user the tendermint app uses
##
#tendermint_user: tendermint
#tendermint_group: tendermint
#tendermint_home: /etc/tendermint
## binary stores the path to the privately built service binary, if there is any. By default it uses the GOPATH environment variable.
#binary: "{{ lookup('env','GOPATH') | default('') }}/bin/{{service}}"
## tendermint_log_file stores the path to the tendermint application log
##
#tendermint_log_file: /var/log/tendermint.log
## config
##
## tendermint_genesis_file contains the path and filename to a previously generated genesis.json. If undefined, the json file is dynamically generated.
##
## tendermint_genesis_file contains the path and filename to a previously generated genesis.json for the underlying tendermint service. If undefined, the json file is dynamically generated.
#tendermint_genesis_file: "<undefined>"
###
### Basecoin installation
###
## service_genesis_file contains the path and filename to a previously generated genesis.json for the service. If undefined, the json file is dynamically generated.
#service_genesis_file: "<undefined>"
## 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.5.2/basecoin_0.5.2_linux_amd64.zip"
## basecoin_binary stores the path to a private basecoin binary to install
##
#basecoin_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/basecoin"
## Details of the linux user the basecoin app uses
##
#basecoin_user: tendermint
#basecoin_group: tendermint
#basecoin_home: /etc/tendermint
## basecoin_log_file stores the path to the basecoin application log
##
#basecoin_log_file: /var/log/basecoin.log
###
### 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 is used to find seed IPs and public keys and set the chain_id in genesis.json and config.toml
#testnet_name: testnet1
## app_options_file contains a path and filename which will be included in a generated genesis.json file on all nodes. The content will be dumped into the app_options dictionary.
## app_options_file contains a path and filename which will be included in a generated service genesis.json file on all nodes. The content will be dumped into the app_options dictionary in the service genesis.json..
#app_options_file: "app_options_files/dev_money"
## validators indicates if the nodes are validator nodes. The tendermint genesis.json will contain their public keys.
#validators: true
## seeds contain the list of servers (with ports) that are validators in a testnet. Only effective if validators == false. If validators == true, then all nodes will be automatically included here.
#seeds: ""
-11
View File
@@ -1,11 +0,0 @@
---
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- install-tendermint
- install-basecoin
- cleanupdata
- { role: config, testnet_name: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" }
- { role: start, service: basecoin }
- { role: start, service: tendermint }
-11
View File
@@ -1,11 +0,0 @@
---
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- install-tendermint
- install-ethermint
- cleanupdata
- { role: config, testnet_name: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" }
- { role: start, service: ethermint }
- { role: start, service: tendermint }
-9
View File
@@ -1,9 +0,0 @@
---
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- install-tendermint
- cleanupdata
- { role: config, testnet_name: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" }
- { role: start, service: tendermint }
+10
View File
@@ -0,0 +1,10 @@
---
#variable "service" is required
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- install
- {role: config, testnet_name: "{{lookup('env','TF_VAR_TESTNET_NAME')}}"}
- start
+1 -3
View File
@@ -4,10 +4,8 @@
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- { role: stop, service: tendermint }
- stop
- cleanupdata
- rmdb
- { role: config, testnet_name: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" }
- start
- { role: start, service: tendermint }
@@ -1,3 +0,0 @@
---
tendermint_home: /etc/tendermint
-7
View File
@@ -1,7 +0,0 @@
---
- name: clear tendermint database
file: "path={{tendermint_home}}/{{item}} state=absent"
with_items:
- data
+5 -6
View File
@@ -1,9 +1,8 @@
---
tendermint_user: tendermint
tendermint_group: tendermint
tendermint_home: /etc/tendermint
#tendermint_genesis_file="<undefined>"
#app_options_file="<undefined>"
#tendermint_genesis_file: "<undefined>"
#service_genesis_file: "<undefined>"
app_options_file: "app_options_files/dev_money"
seeds: ""
testnet_name: testnet1
validators: true
+24 -21
View File
@@ -1,41 +1,44 @@
---
- name: generate tendermint keys
shell: "tendermint gen_validator > {{tendermint_home}}/priv_validator.json"
args:
warn: no
creates: "{{tendermint_home}}/priv_validator.json"
- name: secure priv_validator.json
file: "path={{tendermint_home}}/priv_validator.json mode=0400 owner={{tendermint_user}} group={{tendermint_group}}"
- name: gather tendermint public keys
when: tendermint_genesis_file is not defined
command: "jq '.pub_key | .data' {{tendermint_home}}/priv_validator.json"
when: validators == true and tendermint_genesis_file is not defined
command: "jq '.pub_key | .data' /etc/{{service}}/tendermint/priv_validator.json"
register: pubkeys
changed_when: false
- name: register tendermint public keys as host facts
when: tendermint_genesis_file is not defined
when: validators == true and tendermint_genesis_file is not defined
set_fact: "pubkey={{pubkeys.stdout_lines[0]}}"
connection: local
- name: copy generated tendermint genesis.json - genesis_time will be updated
when: tendermint_genesis_file is not defined
template:
src: genesis.json.j2
dest: "{{tendermint_home}}/genesis.json"
owner: "{{tendermint_user}}"
group: "{{tendermint_group}}"
src: genesis-server.json.j2
dest: "/etc/{{service}}/tendermint/genesis.json"
owner: "{{service}}"
group: "{{service}}"
- name: copy pre-created genesis.json
- name: copy generated service genesis.json - genesis_time will be updated
when: service_genesis_file is not defined
template:
src: genesis-service.json.j2
dest: "/etc/{{service}}/genesis.json"
owner: "{{service}}"
group: "{{service}}"
- name: copy pre-created tendermint genesis.json
when: tendermint_genesis_file is defined
copy: "src={{tendermint_genesis_file}} dest={{tendermint_home}}/genesis.json owner={{tendermint_user}} group={{tendermint_group}}"
copy: "src={{tendermint_genesis_file}} dest=/etc/{{service}}/tendermint/genesis.json owner={{service}} group={{service}}"
- name: copy pre-created service genesis.json
when: service_genesis_file is defined
copy: "src={{service_genesis_file}} dest=/etc/{{service}}/genesis.json owner={{service}} group={{service}}"
- name: copy tendermint config.toml
template:
src: config.toml.j2
dest: "{{tendermint_home}}/config.toml"
owner: "{{tendermint_user}}"
group: "{{tendermint_group}}"
dest: "/etc/{{service}}/tendermint/config.toml"
owner: "{{service}}"
group: "{{service}}"
@@ -1,16 +1,19 @@
# This is a TOML config file.
# For more information, see https://github.com/toml-lang/toml
proxy_app = "tcp://127.0.0.1:46658"
proxy_app = "tcp://127.0.0.1:{{(service == 'basecoin') | ternary('36658','46658')}}"
moniker = "{{inventory_hostname}}"
fast_sync = true
db_backend = "leveldb"
log_level = "debug"
[rpc]
laddr = "tcp://0.0.0.0:46657"
laddr = "tcp://0.0.0.0:{{(service == 'basecoin') | ternary('36657','46657')}}"
[p2p]
laddr = "tcp://0.0.0.0:46656"
{% set comma = joiner(",") %}seeds = "{% for host in groups[testnet_name]|difference(inventory_hostname) %}{{ comma() }}{{hostvars[host]["inventory_hostname"]}}:46656{% endfor %}"
laddr = "tcp://0.0.0.0:{{(service == 'basecoin') | ternary('36656','46656')}}"
{% if validators == true %}
{% set comma = joiner(",") %}seeds = "{% for host in groups[testnet_name]|difference(inventory_hostname) %}{{ comma() }}{{hostvars[host]["inventory_hostname"]}}:{{(service == 'basecoin') | ternary('36656','46656')}}{% endfor %}"
{% else %}
seeds = "{{ seeds | default() }}"
{% endif %}
@@ -3,6 +3,7 @@
"chain_id":"{{testnet_name}}",
"validators":
[
{% if validators == true %}
{% set comma = joiner(",") %}
{% for host in groups[testnet_name] %}
{{ comma() }}
@@ -12,12 +13,9 @@
"name":"{{hostvars[host]["ansible_hostname"]}}"
}
{% endfor %}
{% endif %}
],
"app_hash":"",
"app_options": {
{% if app_options_file is defined %}
{% include app_options_file %}
{% endif %}
}
"app_options": {}
}
@@ -0,0 +1,12 @@
{
"genesis_time":"{{ansible_date_time.iso8601}}",
"chain_id":"{{testnet_name}}",
"validators": [],
"app_hash":"",
"app_options": {
{% if app_options_file is defined %}
{% include app_options_file %}
{% endif %}
}
}
@@ -1,2 +0,0 @@
[defaults]
roles_path = ../
@@ -1,12 +0,0 @@
---
basecoin_release_install: true
basecoin_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/basecoin/v0.5.2/basecoin_0.5.2_linux_amd64.zip"
basecoin_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/basecoin"
basecoin_user: tendermint
basecoin_group: tendermint
basecoin_home: /etc/tendermint
basecoin_log_file: /var/log/basecoin.log
@@ -1,11 +0,0 @@
{
"address": "1B1BE55F969F54064628A63B9559E7C21C925165",
"priv_key": {
"type": "ed25519",
"data": "C70D6934B4F55F1B7BC33B56B9CA8A2061384AFC19E91E44B40C4BBA182953D1619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279"
},
"pub_key": {
"type": "ed25519",
"data": "619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279"
}
}
@@ -1,11 +0,0 @@
{
"address": "1DA7C74F9C219229FD54CC9F7386D5A3839F0090",
"priv_key": {
"type": "ed25519",
"data": "34BAE9E65CE8245FAD035A0E3EED9401BDE8785FFB3199ACCF8F5B5DDF7486A8352195DA90CB0B90C24295B90AEBA25A5A71BC61BAB2FE2387241D439698B7B8"
},
"pub_key": {
"type": "ed25519",
"data": "352195DA90CB0B90C24295B90AEBA25A5A71BC61BAB2FE2387241D439698B7B8"
}
}
@@ -1,5 +0,0 @@
---
- name: reload systemd
command: systemctl daemon-reload
@@ -1,114 +0,0 @@
---
- name: update apt
apt: >
update_cache=yes
cache_valid_time=3600
when: ansible_os_family == "Debian"
- name: install deps (Ubuntu)
apt: >
pkg={{item}}
state=installed
with_items:
- unzip
- jq
when: ansible_os_family == "Debian"
- name: install deps (RHEL)
yum: >
pkg={{item}}
state=installed
with_items:
- unzip
- jq
when: ansible_os_family == "RedHat"
- name: create group
group: >
name={{basecoin_group}}
state=present
system=yes
register: basecoin_group_created
- name: create user
user: >
home={{basecoin_home}}
name={{basecoin_user}}
group={{basecoin_group}}
system=yes
when: basecoin_group_created|changed
- name: create directory
file: >
path={{basecoin_home}}
state=directory
owner={{basecoin_user}}
group={{basecoin_group}}
mode=0755
# Check before creating log dir to prevent aggressively overwriting permissions
- name: check for log directory
stat: >
path={{ basecoin_log_file|dirname }}
register: logdir
- name: create log directory if it does not exist
file: >
state=directory
path={{ basecoin_log_file|dirname }}
owner={{ basecoin_user }}
group={{ basecoin_group }}
when: not logdir.stat.exists
- name: touch the log file
file: >
state=touch
path={{ basecoin_log_file }}
owner={{ basecoin_user }}
group={{ basecoin_group }}
changed_when: false
- name: copy and unpack release binary
when: basecoin_release_install|bool
unarchive: >
src={{basecoin_download}}
dest=/usr/local/bin
remote_src=true
mode=0755
- name: copy compiled binary
when: not basecoin_release_install|bool
copy: >
src={{basecoin_binary}}
dest=/usr/local/bin
mode=0755
- name: copy upstart script
template: >
src=basecoin.conf.j2
dest=/etc/init/basecoin.conf
owner=root
group=root
mode=0644
when: "ansible_service_mgr == 'upstart'"
- name: copy systemd script
template: >
src=basecoin.systemd.j2
dest=/etc/systemd/system/basecoin.service
owner=root
group=root
mode=0644
when: "ansible_service_mgr == 'systemd'"
notify:
- reload systemd
- name: Create example folder
file: path=/usr/share/basecoin/dev-keys state=directory
- name: Copy example keys
copy: "src={{item}} dest=/usr/share/basecoin/dev-keys/{{item}}"
with_items:
- key.json
- key2.json
@@ -1,8 +0,0 @@
---
- name: gather OS specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version}}.yml"
- "{{ ansible_os_family }}.yml"
- include: install.yml
@@ -1,15 +0,0 @@
# Basecoin (Upstart unit)
description "Basecoin"
start on runlevel [2345]
stop on runlevel [!2345]
script
# Use su to become tendermint user non-interactively on old Upstart versions (see http://superuser.com/a/234541/76168)
exec su -s /bin/sh -c 'BCHOME={{basecoin_home}} exec "$0" "$@" >> {{ basecoin_log_file }} 2>&1' {{basecoin_user}} -- /usr/local/bin/basecoin start --without-tendermint
end script
respawn
respawn limit 10 10
kill timeout 10
@@ -1,17 +0,0 @@
[Unit]
Description=Basecoin
Requires=network-online.target
After=network-online.target
[Service]
Environment="BCHOME={{basecoin_home}}"
Restart=on-failure
User={{ basecoin_user }}
Group={{ basecoin_group }}
PermissionsStartOnly=true
ExecStart=/usr/local/bin/basecoin start --without-tendermint
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
@@ -1,2 +0,0 @@
---
#Placeholder
@@ -1,2 +0,0 @@
---
#Placeholder
@@ -1,11 +0,0 @@
---
ethermint_release_install: true
ethermint_download: "https://s3.eu-central-1.amazonaws.com/ethermint/0.2.0/ethermint_0.2.0_ethermint-linux-amd64.zip"
ethermint_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/ethermint"
ethermint_user: tendermint
ethermint_group: tendermint
ethermint_home: /etc/tendermint
ethermint_log_file: /var/log/ethermint.log
@@ -1,5 +0,0 @@
---
- name: reload systemd
command: systemctl daemon-reload
@@ -1,104 +0,0 @@
---
- name: update apt
apt: >
update_cache=yes
cache_valid_time=3600
when: ansible_os_family == "Debian"
- name: install deps (Ubuntu)
apt: >
pkg={{item}}
state=installed
with_items:
- unzip
- jq
when: ansible_os_family == "Debian"
- name: install deps (RHEL)
yum: >
pkg={{item}}
state=installed
with_items:
- unzip
- jq
when: ansible_os_family == "RedHat"
- name: create group
group: >
name={{ethermint_group}}
state=present
system=yes
register: ethermint_group_created
- name: create user
user: >
home={{ethermint_home}}
name={{ethermint_user}}
group={{ethermint_group}}
system=yes
when: ethermint_group_created|changed
- name: create directory
file: >
path={{ethermint_home}}
state=directory
owner={{ethermint_user}}
group={{ethermint_group}}
mode=0755
# Check before creating log dir to prevent aggressively overwriting permissions
- name: check for log directory
stat: >
path={{ ethermint_log_file|dirname }}
register: logdir
- name: create log directory if it does not exist
file: >
state=directory
path={{ ethermint_log_file|dirname }}
owner={{ ethermint_user }}
group={{ ethermint_group }}
when: not logdir.stat.exists
- name: touch the log file
file: >
state=touch
path={{ ethermint_log_file }}
owner={{ ethermint_user }}
group={{ ethermint_group }}
changed_when: false
- name: copy and unpack release binary
when: ethermint_release_install|bool
unarchive: >
src={{ethermint_download}}
dest=/usr/local/bin
remote_src=true
mode=0755
- name: copy compiled binary
when: not ethermint_release_install|bool
copy: >
src={{ethermint_binary}}
dest=/usr/local/bin
mode=0755
- name: copy upstart script
template: >
src=ethermint.conf.j2
dest=/etc/init/ethermint.conf
owner=root
group=root
mode=0644
when: "ansible_service_mgr == 'upstart'"
- name: copy systemd script
template: >
src=ethermint.systemd.j2
dest=/etc/systemd/system/ethermint.service
owner=root
group=root
mode=0644
when: "ansible_service_mgr == 'systemd'"
notify:
- reload systemd
@@ -1,8 +0,0 @@
---
- name: gather OS specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version}}.yml"
- "{{ ansible_os_family }}.yml"
- include: install.yml
@@ -1,15 +0,0 @@
# Ethermint (Upstart unit)
description "Ethermint"
start on runlevel [2345]
stop on runlevel [!2345]
script
# Use su to become ethermint user non-interactively on old Upstart versions (see http://superuser.com/a/234541/76168)
exec su -s /bin/sh -c 'EMHOME={{ethermint_home}} exec "$0" "$@" >> {{ ethermint_log_file }} 2>&1' {{ ethermint_user }} -- /usr/local/bin/ethermint start
end script
respawn
respawn limit 10 10
kill timeout 10
@@ -1,17 +0,0 @@
[Unit]
Description=Ethermint
Requires=network-online.target
After=network-online.target
[Service]
Environment="EMHOME={{ethermint_home}}"
Restart=on-failure
User={{ ethermint_user }}
Group={{ ethermint_group }}
PermissionsStartOnly=true
ExecStart=/usr/local/bin/ethermint start
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
@@ -1,2 +0,0 @@
---
#Placeholder
@@ -1,2 +0,0 @@
---
#Placeholder
@@ -1,12 +0,0 @@
---
tendermint_release_install: true
tendermint_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/tendermint/v0.10.0/tendermint_0.10.0_linux_amd64.zip"
tendermint_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/tendermint"
tendermint_user: tendermint
tendermint_group: tendermint
tendermint_home: /etc/tendermint
tendermint_log_file: /var/log/tendermint.log
@@ -1,5 +0,0 @@
---
- name: reload systemd
command: systemctl daemon-reload
@@ -1,104 +0,0 @@
---
- name: update apt
apt: >
update_cache=yes
cache_valid_time=3600
when: ansible_os_family == "Debian"
- name: install deps (Ubuntu)
apt: >
pkg={{item}}
state=installed
with_items:
- unzip
- jq
when: ansible_os_family == "Debian"
- name: install deps (RHEL)
yum: >
pkg={{item}}
state=installed
with_items:
- unzip
- jq
when: ansible_os_family == "RedHat"
- name: create group
group: >
name={{tendermint_group}}
state=present
system=yes
register: tendermint_group_created
- name: create user
user: >
home={{tendermint_home}}
name={{tendermint_user}}
group={{tendermint_group}}
system=yes
when: tendermint_group_created|changed
- name: create directory
file: >
path={{tendermint_home}}
state=directory
owner={{tendermint_user}}
group={{tendermint_group}}
mode=0755
# Check before creating log dir to prevent aggressively overwriting permissions
- name: check for log directory
stat: >
path={{ tendermint_log_file|dirname }}
register: logdir
- name: create log directory if it does not exist
file: >
state=directory
path={{ tendermint_log_file|dirname }}
owner={{ tendermint_user }}
group={{ tendermint_group }}
when: not logdir.stat.exists
- name: touch the log file
file: >
state=touch
path={{ tendermint_log_file }}
owner={{ tendermint_user }}
group={{ tendermint_group }}
changed_when: false
- name: copy and unpack release binary
when: tendermint_release_install|bool
unarchive: >
src={{tendermint_download}}
dest=/usr/local/bin
remote_src=true
mode=0755
- name: copy compiled binary
when: not tendermint_release_install|bool
copy: >
src={{tendermint_binary}}
dest=/usr/local/bin
mode=0755
- name: copy upstart script
template: >
src=tendermint.conf.j2
dest=/etc/init/tendermint.conf
owner=root
group=root
mode=0644
when: "ansible_service_mgr == 'upstart'"
- name: copy systemd script
template: >
src=tendermint.systemd.j2
dest=/etc/systemd/system/tendermint.service
owner=root
group=root
mode=0644
when: "ansible_service_mgr == 'systemd'"
notify:
- reload systemd
@@ -1,8 +0,0 @@
---
- name: gather OS specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version}}.yml"
- "{{ ansible_os_family }}.yml"
- include: install.yml
@@ -1,15 +0,0 @@
# Tendermint (Upstart unit)
description "Tendermint"
start on (runlevel [2345] and started basecoin)
stop on (runlevel [!2345] and stopping basecoin)
script
# Use su to become tendermint user non-interactively on old Upstart versions (see http://superuser.com/a/234541/76168)
exec su -s /bin/sh -c 'TMHOME={{tendermint_home}} exec "$0" "$@" >> {{ tendermint_log_file }} 2>&1' {{ tendermint_user }} -- /usr/local/bin/tendermint node
end script
respawn
respawn limit 10 10
kill timeout 10
@@ -1,17 +0,0 @@
[Unit]
Description=Tendermint
Requires=network-online.target basecoin.target
After=network-online.target
[Service]
Environment="TMHOME={{tendermint_home}}"
Restart=on-failure
User={{ tendermint_user }}
Group={{ tendermint_group }}
PermissionsStartOnly=true
ExecStart=/usr/local/bin/tendermint node
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
@@ -1,2 +0,0 @@
---
#Placeholder
@@ -1,2 +0,0 @@
---
#Placeholder
+4
View File
@@ -0,0 +1,4 @@
---
release_install: true
binary: "{{ lookup('env','GOPATH') | default('') }}/bin/{{service}}"
+20
View File
@@ -0,0 +1,20 @@
---
- name: Add tendermint repository and key on CentOS/RedHat
when: ansible_os_family == "RedHat"
yum_repository:
name: tendermint
baseurl: repo.testnets.interblock.io/centos
ui_repoid_vars: 7 os x86_64
description: "Tendermint repo"
gpgcheck: yes
gpgkey: repo.testnets.interblock.io/centos/RPM-GPG-KEY-Tendermint
repo_gpgcheck: yes
- name: Install package on CentOS/RedHat
when: ansible_os_family == "RedHat"
yum: pkg={{item}}
with_items:
- unzip
- jq
- {{service}}
+20
View File
@@ -0,0 +1,20 @@
---
- name: Add repository key on Debian/Ubuntu
when: ansible_os_family == "Debian"
apt_key:
url: http://tendermint-packages.s3-website-us-west-1.amazonaws.com/centos/7/os/x86_64/RPM-GPG-KEY-Tendermint
id: 2122CBE9
- name: Install tendermint repository on Debian/Ubuntu
when: ansible_os_family == "Debian"
apt_repository:
repo: deb http://tendermint-packages.s3-website-us-west-1.amazonaws.com/debian stable main
- name: Install package on Debian/Ubuntu
when: ansible_os_family == "Debian"
apt: pkg={{item}}
with_items:
- unzip
- jq
- {{service}}
+14
View File
@@ -0,0 +1,14 @@
---
- include: debian.yml
when: ansible_os_family == "Debian"
- include: centos.yml
when: ansible_os_family == "RedHat"
- name: copy compiled binary
when: not release_install|bool
copy:
src: "{{binary}}"
dest: /usr/local/bin
mode: 0755
+7
View File
@@ -0,0 +1,7 @@
---
- name: clear tendermint database
file: "path=/etc/{{service}}/tendermint/{{item}} state=absent"
with_items:
- data
-7
View File
@@ -1,7 +0,0 @@
---
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- { role: start, service: "basecoin" }
- { role: start, service: "tendermint" }
-7
View File
@@ -1,7 +0,0 @@
---
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- { role: start, service: "ethermint" }
- { role: start, service: "tendermint" }
-7
View File
@@ -1,7 +0,0 @@
---
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- { role: stop, service: "tendermint"}
- { role: stop, service: "basecoin"}
-7
View File
@@ -1,7 +0,0 @@
---
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles:
- { role: stop, service: "tendermint"}
- { role: stop, service: "ethermint"}
+1 -1
View File
@@ -4,7 +4,7 @@ variable "name" {
variable "image_id" {
description = "Image ID"
default = "ubuntu-14-04-x64"
default = "ubuntu-16-04-x64"
}
variable "regions" {
+1 -1
View File
@@ -30,7 +30,7 @@ variable "servers" {
variable "image" {
description = "DigitalOcean image name"
default = "ubuntu-14-04-x64"
default = "ubuntu-16-04-x64"
}
variable "noroot" {