From 7239e41c4a2dac21310ea5173bf5139d84c07239 Mon Sep 17 00:00:00 2001 From: Greg Szabo Date: Sun, 18 Jun 2017 01:57:07 +0000 Subject: [PATCH] Ansible refactor: uses package repositories. Added option to separately update service/tendermint genesis.json --- ansible/README.md | 40 ++--- ansible/config-tendermint.yml | 6 - ansible/config.toml | 16 ++ ansible/genesis.json | 153 ++++++++++++++++++ ansible/group_vars/all | 67 +++----- ansible/install-basecoin.yml | 11 -- ansible/install-ethermint.yml | 11 -- ansible/install-tendermint-core.yml | 9 -- ansible/install.yml | 10 ++ ansible/reset.yml | 4 +- ansible/roles/cleanupdata/defaults/main.yml | 3 - ansible/roles/cleanupdata/tasks/main.yml | 7 - ansible/roles/config/defaults/main.yml | 11 +- ansible/roles/config/tasks/main.yml | 45 +++--- ansible/roles/config/templates/config.toml.j2 | 13 +- ...genesis.json.j2 => genesis-server.json.j2} | 8 +- .../config/templates/genesis-service.json.j2 | 12 ++ ansible/roles/install-basecoin/ansible.cfg | 2 - .../roles/install-basecoin/defaults/main.yml | 12 -- ansible/roles/install-basecoin/files/key.json | 11 -- .../roles/install-basecoin/files/key2.json | 11 -- .../roles/install-basecoin/handlers/main.yml | 5 - .../roles/install-basecoin/tasks/install.yml | 114 ------------- ansible/roles/install-basecoin/tasks/main.yml | 8 - .../templates/basecoin.conf.j2 | 15 -- .../templates/basecoin.systemd.j2 | 17 -- .../roles/install-basecoin/vars/Debian.yml | 2 - .../roles/install-basecoin/vars/RedHat.yml | 2 - .../roles/install-ethermint/defaults/main.yml | 11 -- .../roles/install-ethermint/handlers/main.yml | 5 - .../roles/install-ethermint/tasks/install.yml | 104 ------------ .../roles/install-ethermint/tasks/main.yml | 8 - .../templates/ethermint.conf.j2 | 15 -- .../templates/ethermint.systemd.j2 | 17 -- .../roles/install-ethermint/vars/Debian.yml | 2 - .../roles/install-ethermint/vars/RedHat.yml | 2 - .../install-tendermint/defaults/main.yml | 12 -- .../install-tendermint/handlers/main.yml | 5 - .../install-tendermint/tasks/install.yml | 104 ------------ .../roles/install-tendermint/tasks/main.yml | 8 - .../templates/tendermint.conf.j2 | 15 -- .../templates/tendermint.systemd.j2 | 17 -- .../roles/install-tendermint/vars/Debian.yml | 2 - .../roles/install-tendermint/vars/RedHat.yml | 2 - ansible/roles/install/defaults/main.yml | 4 + ansible/roles/install/tasks/centos.yml | 20 +++ ansible/roles/install/tasks/debian.yml | 20 +++ ansible/roles/install/tasks/main.yml | 14 ++ ansible/roles/rmdb/tasks/main.yml | 7 + ansible/start-basecoin.yml | 7 - ansible/start-ethermint.yml | 7 - ansible/stop-basecoin.yml | 7 - ansible/stop-ethermint.yml | 7 - terraform-digitalocean/cluster/variables.tf | 2 +- terraform-digitalocean/main.tf | 2 +- 55 files changed, 332 insertions(+), 719 deletions(-) delete mode 100644 ansible/config-tendermint.yml create mode 100644 ansible/config.toml create mode 100644 ansible/genesis.json delete mode 100644 ansible/install-basecoin.yml delete mode 100644 ansible/install-ethermint.yml delete mode 100644 ansible/install-tendermint-core.yml create mode 100644 ansible/install.yml delete mode 100644 ansible/roles/cleanupdata/defaults/main.yml delete mode 100644 ansible/roles/cleanupdata/tasks/main.yml rename ansible/roles/config/templates/{genesis.json.j2 => genesis-server.json.j2} (81%) create mode 100644 ansible/roles/config/templates/genesis-service.json.j2 delete mode 100644 ansible/roles/install-basecoin/ansible.cfg delete mode 100644 ansible/roles/install-basecoin/defaults/main.yml delete mode 100644 ansible/roles/install-basecoin/files/key.json delete mode 100644 ansible/roles/install-basecoin/files/key2.json delete mode 100644 ansible/roles/install-basecoin/handlers/main.yml delete mode 100644 ansible/roles/install-basecoin/tasks/install.yml delete mode 100644 ansible/roles/install-basecoin/tasks/main.yml delete mode 100644 ansible/roles/install-basecoin/templates/basecoin.conf.j2 delete mode 100644 ansible/roles/install-basecoin/templates/basecoin.systemd.j2 delete mode 100644 ansible/roles/install-basecoin/vars/Debian.yml delete mode 100644 ansible/roles/install-basecoin/vars/RedHat.yml delete mode 100644 ansible/roles/install-ethermint/defaults/main.yml delete mode 100644 ansible/roles/install-ethermint/handlers/main.yml delete mode 100644 ansible/roles/install-ethermint/tasks/install.yml delete mode 100644 ansible/roles/install-ethermint/tasks/main.yml delete mode 100644 ansible/roles/install-ethermint/templates/ethermint.conf.j2 delete mode 100644 ansible/roles/install-ethermint/templates/ethermint.systemd.j2 delete mode 100644 ansible/roles/install-ethermint/vars/Debian.yml delete mode 100644 ansible/roles/install-ethermint/vars/RedHat.yml delete mode 100644 ansible/roles/install-tendermint/defaults/main.yml delete mode 100644 ansible/roles/install-tendermint/handlers/main.yml delete mode 100644 ansible/roles/install-tendermint/tasks/install.yml delete mode 100644 ansible/roles/install-tendermint/tasks/main.yml delete mode 100644 ansible/roles/install-tendermint/templates/tendermint.conf.j2 delete mode 100644 ansible/roles/install-tendermint/templates/tendermint.systemd.j2 delete mode 100644 ansible/roles/install-tendermint/vars/Debian.yml delete mode 100644 ansible/roles/install-tendermint/vars/RedHat.yml create mode 100644 ansible/roles/install/defaults/main.yml create mode 100644 ansible/roles/install/tasks/centos.yml create mode 100644 ansible/roles/install/tasks/debian.yml create mode 100644 ansible/roles/install/tasks/main.yml create mode 100644 ansible/roles/rmdb/tasks/main.yml delete mode 100644 ansible/start-basecoin.yml delete mode 100644 ansible/start-ethermint.yml delete mode 100644 ansible/stop-basecoin.yml delete mode 100644 ansible/stop-ethermint.yml diff --git a/ansible/README.md b/ansible/README.md index eb023ba0b..a8c2b7995 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -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="" 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='' AWS_SECRET_ACCESS_KEY='' 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="" -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="" 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=`, 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=`, like `-e service=basecoin`. It will restart the underlying tendermint application too. * stop.yml - Stop the application. You need to pass `-e service=`. * start.yml - Start the application. You need to pass `-e service=`. -* 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. diff --git a/ansible/config-tendermint.yml b/ansible/config-tendermint.yml deleted file mode 100644 index 99d25de56..000000000 --- a/ansible/config-tendermint.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" - roles: - - { role: config, testnet_name: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" } - diff --git a/ansible/config.toml b/ansible/config.toml new file mode 100644 index 000000000..42cc8a4fe --- /dev/null +++ b/ansible/config.toml @@ -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" + diff --git a/ansible/genesis.json b/ansible/genesis.json new file mode 100644 index 000000000..feb0000f0 --- /dev/null +++ b/ansible/genesis.json @@ -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 + } + ] + } + ] + } +} + diff --git a/ansible/group_vars/all b/ansible/group_vars/all index cf3dad6dd..05345b129 100644 --- a/ansible/group_vars/all +++ b/ansible/group_vars/all @@ -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 - -## tendermint_download stores the link to the specific tendermint release to install +## install ## -#tendermint_download: "https://s3-us-west-2.amazonaws.com/tendermint/binaries/tendermint/v0.10.0/tendermint_0.10.0_linux_amd64.zip" -## tendermint_binary stores the path to a private tendermint binary to install -## -#tendermint_binary: "{{ lookup('env','GOPATH') | default('') }}/bin/tendermint" +## service variable defines which service is going to be managed. It can be set to basecoin or ethermint. +service: basecoin -## Details of the linux user the tendermint app uses -## -#tendermint_user: tendermint -#tendermint_group: tendermint -#tendermint_home: /etc/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 -## tendermint_log_file stores the path to the tendermint application log -## -#tendermint_log_file: /var/log/tendermint.log +## 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_genesis_file contains the path and filename to a previously generated genesis.json. If undefined, the json file is dynamically generated. ## -#tendermint_genesis_file: "" - -### -### Basecoin installation -### - -## 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 +## config ## -#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 +## 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: "" -### -### Development settings -### +## 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: "" -## 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: "" diff --git a/ansible/install-basecoin.yml b/ansible/install-basecoin.yml deleted file mode 100644 index a9d4e0212..000000000 --- a/ansible/install-basecoin.yml +++ /dev/null @@ -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 } - diff --git a/ansible/install-ethermint.yml b/ansible/install-ethermint.yml deleted file mode 100644 index 1c28fbeb4..000000000 --- a/ansible/install-ethermint.yml +++ /dev/null @@ -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 } - diff --git a/ansible/install-tendermint-core.yml b/ansible/install-tendermint-core.yml deleted file mode 100644 index 735c1cbf8..000000000 --- a/ansible/install-tendermint-core.yml +++ /dev/null @@ -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 } - diff --git a/ansible/install.yml b/ansible/install.yml new file mode 100644 index 000000000..31e9ba53a --- /dev/null +++ b/ansible/install.yml @@ -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 + diff --git a/ansible/reset.yml b/ansible/reset.yml index d863e96b4..7463f679f 100644 --- a/ansible/reset.yml +++ b/ansible/reset.yml @@ -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 } diff --git a/ansible/roles/cleanupdata/defaults/main.yml b/ansible/roles/cleanupdata/defaults/main.yml deleted file mode 100644 index ebb74e6ce..000000000 --- a/ansible/roles/cleanupdata/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -tendermint_home: /etc/tendermint - diff --git a/ansible/roles/cleanupdata/tasks/main.yml b/ansible/roles/cleanupdata/tasks/main.yml deleted file mode 100644 index f5e378119..000000000 --- a/ansible/roles/cleanupdata/tasks/main.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- name: clear tendermint database - file: "path={{tendermint_home}}/{{item}} state=absent" - with_items: - - data - diff --git a/ansible/roles/config/defaults/main.yml b/ansible/roles/config/defaults/main.yml index 71d520189..34a5ab120 100644 --- a/ansible/roles/config/defaults/main.yml +++ b/ansible/roles/config/defaults/main.yml @@ -1,9 +1,8 @@ --- -tendermint_user: tendermint -tendermint_group: tendermint -tendermint_home: /etc/tendermint - -#tendermint_genesis_file="" -#app_options_file="" +#tendermint_genesis_file: "" +#service_genesis_file: "" +app_options_file: "app_options_files/dev_money" +seeds: "" testnet_name: testnet1 +validators: true diff --git a/ansible/roles/config/tasks/main.yml b/ansible/roles/config/tasks/main.yml index 49a6ce749..2b3e5c675 100644 --- a/ansible/roles/config/tasks/main.yml +++ b/ansible/roles/config/tasks/main.yml @@ -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}}" diff --git a/ansible/roles/config/templates/config.toml.j2 b/ansible/roles/config/templates/config.toml.j2 index 7dfdbb787..652f82324 100644 --- a/ansible/roles/config/templates/config.toml.j2 +++ b/ansible/roles/config/templates/config.toml.j2 @@ -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 %} diff --git a/ansible/roles/config/templates/genesis.json.j2 b/ansible/roles/config/templates/genesis-server.json.j2 similarity index 81% rename from ansible/roles/config/templates/genesis.json.j2 rename to ansible/roles/config/templates/genesis-server.json.j2 index 5d50a0a4b..c8dd4635a 100644 --- a/ansible/roles/config/templates/genesis.json.j2 +++ b/ansible/roles/config/templates/genesis-server.json.j2 @@ -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": {} } diff --git a/ansible/roles/config/templates/genesis-service.json.j2 b/ansible/roles/config/templates/genesis-service.json.j2 new file mode 100644 index 000000000..7f9a48316 --- /dev/null +++ b/ansible/roles/config/templates/genesis-service.json.j2 @@ -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 %} + } +} + diff --git a/ansible/roles/install-basecoin/ansible.cfg b/ansible/roles/install-basecoin/ansible.cfg deleted file mode 100644 index 613d83b12..000000000 --- a/ansible/roles/install-basecoin/ansible.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[defaults] -roles_path = ../ diff --git a/ansible/roles/install-basecoin/defaults/main.yml b/ansible/roles/install-basecoin/defaults/main.yml deleted file mode 100644 index 001978554..000000000 --- a/ansible/roles/install-basecoin/defaults/main.yml +++ /dev/null @@ -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 - diff --git a/ansible/roles/install-basecoin/files/key.json b/ansible/roles/install-basecoin/files/key.json deleted file mode 100644 index c557b2204..000000000 --- a/ansible/roles/install-basecoin/files/key.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "address": "1B1BE55F969F54064628A63B9559E7C21C925165", - "priv_key": { - "type": "ed25519", - "data": "C70D6934B4F55F1B7BC33B56B9CA8A2061384AFC19E91E44B40C4BBA182953D1619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279" - }, - "pub_key": { - "type": "ed25519", - "data": "619D3678599971ED29C7529DDD4DA537B97129893598A17C82E3AC9A8BA95279" - } -} \ No newline at end of file diff --git a/ansible/roles/install-basecoin/files/key2.json b/ansible/roles/install-basecoin/files/key2.json deleted file mode 100644 index 4ccb43f60..000000000 --- a/ansible/roles/install-basecoin/files/key2.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "address": "1DA7C74F9C219229FD54CC9F7386D5A3839F0090", - "priv_key": { - "type": "ed25519", - "data": "34BAE9E65CE8245FAD035A0E3EED9401BDE8785FFB3199ACCF8F5B5DDF7486A8352195DA90CB0B90C24295B90AEBA25A5A71BC61BAB2FE2387241D439698B7B8" - }, - "pub_key": { - "type": "ed25519", - "data": "352195DA90CB0B90C24295B90AEBA25A5A71BC61BAB2FE2387241D439698B7B8" - } -} \ No newline at end of file diff --git a/ansible/roles/install-basecoin/handlers/main.yml b/ansible/roles/install-basecoin/handlers/main.yml deleted file mode 100644 index 3427a0144..000000000 --- a/ansible/roles/install-basecoin/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -- name: reload systemd - command: systemctl daemon-reload - diff --git a/ansible/roles/install-basecoin/tasks/install.yml b/ansible/roles/install-basecoin/tasks/install.yml deleted file mode 100644 index 2007fadcf..000000000 --- a/ansible/roles/install-basecoin/tasks/install.yml +++ /dev/null @@ -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 - diff --git a/ansible/roles/install-basecoin/tasks/main.yml b/ansible/roles/install-basecoin/tasks/main.yml deleted file mode 100644 index 6f77828d9..000000000 --- a/ansible/roles/install-basecoin/tasks/main.yml +++ /dev/null @@ -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 - diff --git a/ansible/roles/install-basecoin/templates/basecoin.conf.j2 b/ansible/roles/install-basecoin/templates/basecoin.conf.j2 deleted file mode 100644 index 91573c1a2..000000000 --- a/ansible/roles/install-basecoin/templates/basecoin.conf.j2 +++ /dev/null @@ -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 diff --git a/ansible/roles/install-basecoin/templates/basecoin.systemd.j2 b/ansible/roles/install-basecoin/templates/basecoin.systemd.j2 deleted file mode 100644 index 82ffe36ff..000000000 --- a/ansible/roles/install-basecoin/templates/basecoin.systemd.j2 +++ /dev/null @@ -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 diff --git a/ansible/roles/install-basecoin/vars/Debian.yml b/ansible/roles/install-basecoin/vars/Debian.yml deleted file mode 100644 index a87f2b258..000000000 --- a/ansible/roles/install-basecoin/vars/Debian.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -#Placeholder diff --git a/ansible/roles/install-basecoin/vars/RedHat.yml b/ansible/roles/install-basecoin/vars/RedHat.yml deleted file mode 100644 index a87f2b258..000000000 --- a/ansible/roles/install-basecoin/vars/RedHat.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -#Placeholder diff --git a/ansible/roles/install-ethermint/defaults/main.yml b/ansible/roles/install-ethermint/defaults/main.yml deleted file mode 100644 index 66c4df8f9..000000000 --- a/ansible/roles/install-ethermint/defaults/main.yml +++ /dev/null @@ -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 - diff --git a/ansible/roles/install-ethermint/handlers/main.yml b/ansible/roles/install-ethermint/handlers/main.yml deleted file mode 100644 index 3427a0144..000000000 --- a/ansible/roles/install-ethermint/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -- name: reload systemd - command: systemctl daemon-reload - diff --git a/ansible/roles/install-ethermint/tasks/install.yml b/ansible/roles/install-ethermint/tasks/install.yml deleted file mode 100644 index 875456ad2..000000000 --- a/ansible/roles/install-ethermint/tasks/install.yml +++ /dev/null @@ -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 diff --git a/ansible/roles/install-ethermint/tasks/main.yml b/ansible/roles/install-ethermint/tasks/main.yml deleted file mode 100644 index 6f77828d9..000000000 --- a/ansible/roles/install-ethermint/tasks/main.yml +++ /dev/null @@ -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 - diff --git a/ansible/roles/install-ethermint/templates/ethermint.conf.j2 b/ansible/roles/install-ethermint/templates/ethermint.conf.j2 deleted file mode 100644 index 1d4c9b45a..000000000 --- a/ansible/roles/install-ethermint/templates/ethermint.conf.j2 +++ /dev/null @@ -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 diff --git a/ansible/roles/install-ethermint/templates/ethermint.systemd.j2 b/ansible/roles/install-ethermint/templates/ethermint.systemd.j2 deleted file mode 100644 index af642e967..000000000 --- a/ansible/roles/install-ethermint/templates/ethermint.systemd.j2 +++ /dev/null @@ -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 diff --git a/ansible/roles/install-ethermint/vars/Debian.yml b/ansible/roles/install-ethermint/vars/Debian.yml deleted file mode 100644 index a87f2b258..000000000 --- a/ansible/roles/install-ethermint/vars/Debian.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -#Placeholder diff --git a/ansible/roles/install-ethermint/vars/RedHat.yml b/ansible/roles/install-ethermint/vars/RedHat.yml deleted file mode 100644 index a87f2b258..000000000 --- a/ansible/roles/install-ethermint/vars/RedHat.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -#Placeholder diff --git a/ansible/roles/install-tendermint/defaults/main.yml b/ansible/roles/install-tendermint/defaults/main.yml deleted file mode 100644 index c6ba51b55..000000000 --- a/ansible/roles/install-tendermint/defaults/main.yml +++ /dev/null @@ -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 - diff --git a/ansible/roles/install-tendermint/handlers/main.yml b/ansible/roles/install-tendermint/handlers/main.yml deleted file mode 100644 index 3427a0144..000000000 --- a/ansible/roles/install-tendermint/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -- name: reload systemd - command: systemctl daemon-reload - diff --git a/ansible/roles/install-tendermint/tasks/install.yml b/ansible/roles/install-tendermint/tasks/install.yml deleted file mode 100644 index e8826b23a..000000000 --- a/ansible/roles/install-tendermint/tasks/install.yml +++ /dev/null @@ -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 diff --git a/ansible/roles/install-tendermint/tasks/main.yml b/ansible/roles/install-tendermint/tasks/main.yml deleted file mode 100644 index 6f77828d9..000000000 --- a/ansible/roles/install-tendermint/tasks/main.yml +++ /dev/null @@ -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 - diff --git a/ansible/roles/install-tendermint/templates/tendermint.conf.j2 b/ansible/roles/install-tendermint/templates/tendermint.conf.j2 deleted file mode 100644 index 21767228c..000000000 --- a/ansible/roles/install-tendermint/templates/tendermint.conf.j2 +++ /dev/null @@ -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 diff --git a/ansible/roles/install-tendermint/templates/tendermint.systemd.j2 b/ansible/roles/install-tendermint/templates/tendermint.systemd.j2 deleted file mode 100644 index b90bb1e0a..000000000 --- a/ansible/roles/install-tendermint/templates/tendermint.systemd.j2 +++ /dev/null @@ -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 diff --git a/ansible/roles/install-tendermint/vars/Debian.yml b/ansible/roles/install-tendermint/vars/Debian.yml deleted file mode 100644 index a87f2b258..000000000 --- a/ansible/roles/install-tendermint/vars/Debian.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -#Placeholder diff --git a/ansible/roles/install-tendermint/vars/RedHat.yml b/ansible/roles/install-tendermint/vars/RedHat.yml deleted file mode 100644 index a87f2b258..000000000 --- a/ansible/roles/install-tendermint/vars/RedHat.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -#Placeholder diff --git a/ansible/roles/install/defaults/main.yml b/ansible/roles/install/defaults/main.yml new file mode 100644 index 000000000..10dad07d4 --- /dev/null +++ b/ansible/roles/install/defaults/main.yml @@ -0,0 +1,4 @@ +--- +release_install: true +binary: "{{ lookup('env','GOPATH') | default('') }}/bin/{{service}}" + diff --git a/ansible/roles/install/tasks/centos.yml b/ansible/roles/install/tasks/centos.yml new file mode 100644 index 000000000..21739326b --- /dev/null +++ b/ansible/roles/install/tasks/centos.yml @@ -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}} + diff --git a/ansible/roles/install/tasks/debian.yml b/ansible/roles/install/tasks/debian.yml new file mode 100644 index 000000000..a72aac369 --- /dev/null +++ b/ansible/roles/install/tasks/debian.yml @@ -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}} + diff --git a/ansible/roles/install/tasks/main.yml b/ansible/roles/install/tasks/main.yml new file mode 100644 index 000000000..60c83bfb7 --- /dev/null +++ b/ansible/roles/install/tasks/main.yml @@ -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 + diff --git a/ansible/roles/rmdb/tasks/main.yml b/ansible/roles/rmdb/tasks/main.yml new file mode 100644 index 000000000..251dd0701 --- /dev/null +++ b/ansible/roles/rmdb/tasks/main.yml @@ -0,0 +1,7 @@ +--- + +- name: clear tendermint database + file: "path=/etc/{{service}}/tendermint/{{item}} state=absent" + with_items: + - data + diff --git a/ansible/start-basecoin.yml b/ansible/start-basecoin.yml deleted file mode 100644 index a91f3a580..000000000 --- a/ansible/start-basecoin.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" - roles: - - { role: start, service: "basecoin" } - - { role: start, service: "tendermint" } - diff --git a/ansible/start-ethermint.yml b/ansible/start-ethermint.yml deleted file mode 100644 index a85b21228..000000000 --- a/ansible/start-ethermint.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" - roles: - - { role: start, service: "ethermint" } - - { role: start, service: "tendermint" } - diff --git a/ansible/stop-basecoin.yml b/ansible/stop-basecoin.yml deleted file mode 100644 index 94ffb4b15..000000000 --- a/ansible/stop-basecoin.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" - roles: - - { role: stop, service: "tendermint"} - - { role: stop, service: "basecoin"} - diff --git a/ansible/stop-ethermint.yml b/ansible/stop-ethermint.yml deleted file mode 100644 index c787a8230..000000000 --- a/ansible/stop-ethermint.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}" - roles: - - { role: stop, service: "tendermint"} - - { role: stop, service: "ethermint"} - diff --git a/terraform-digitalocean/cluster/variables.tf b/terraform-digitalocean/cluster/variables.tf index 411e1f012..92e7c718d 100644 --- a/terraform-digitalocean/cluster/variables.tf +++ b/terraform-digitalocean/cluster/variables.tf @@ -4,7 +4,7 @@ variable "name" { variable "image_id" { description = "Image ID" - default = "ubuntu-14-04-x64" + default = "ubuntu-16-04-x64" } variable "regions" { diff --git a/terraform-digitalocean/main.tf b/terraform-digitalocean/main.tf index bd1225bee..56e20032f 100644 --- a/terraform-digitalocean/main.tf +++ b/terraform-digitalocean/main.tf @@ -30,7 +30,7 @@ variable "servers" { variable "image" { description = "DigitalOcean image name" - default = "ubuntu-14-04-x64" + default = "ubuntu-16-04-x64" } variable "noroot" {