Browse Source

Merged config of application and tendermint

pull/1943/head
Greg Szabo 7 years ago
parent
commit
28e9a0addd
5 changed files with 95 additions and 49 deletions
  1. +2
    -3
      ansible/roles/config/defaults/main.yml
  2. +12
    -26
      ansible/roles/config/tasks/main.yml
  3. +34
    -16
      ansible/roles/config/templates/config.toml.j2
  4. +46
    -0
      ansible/roles/config/templates/genesis.json.j2
  5. +1
    -4
      ansible/roles/generic-service/tasks/main.yml

+ 2
- 3
ansible/roles/config/defaults/main.yml View File

@ -1,7 +1,6 @@
---
#tendermint_genesis_file: "<undefined>"
#service_genesis_file: "<undefined>"
app_options_file: "app_options_files/dev_money"
#genesis_file: "<undefined>"
app_options_file: "app_options_files/public_testnet"
seeds: ""
testnet_name: testnet1
validators: true


+ 12
- 26
ansible/roles/config/tasks/main.yml View File

@ -2,49 +2,37 @@
- name: gather tendermint public keys
when: (validators == true or validators == 'true') and tendermint_genesis_file is not defined
command: "/usr/bin/tendermint show_validator --home /etc/{{service}}/tendermint --log_level error"
command: "/usr/bin/tendermint show_validator --home /etc/{{service}} --log_level error"
register: pubkeys
changed_when: false
- name: resetting permissions from root after gathering public keys
file: "path=/etc/{{service}}/tendermint owner={{service}} group={{service}} recurse=yes"
file: "path=/etc/{{service}} owner={{service}} group={{service}} recurse=yes"
- name: register tendermint public keys as host facts
when: (validators == true or validators == 'true') and tendermint_genesis_file is not defined
set_fact: "pubkey='{{pubkeys.stdout}}'"
connection: local
- name: copy generated tendermint genesis.json - genesis_time will be updated
when: (validators == true or validators == 'true') and tendermint_genesis_file is not defined
template:
src: genesis-server.json.j2
dest: "/etc/{{service}}/tendermint/genesis.json"
owner: "{{service}}"
group: "{{service}}"
- name: copy generated service genesis.json - genesis_time will be updated
tags: reconfig-appgenesis
when: (validators == true or validators == 'true') and (service_genesis_file is not defined) and (service != 'ethermint')
- name: copy generated genesis.json - genesis_time will be updated
when: (validators == true or validators == 'true') and (genesis_file is not defined)
tags: reconfig-genesis
template:
src: genesis-service.json.j2
src: genesis.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=/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 pre-created genesis.json
when: genesis_file is defined
copy: "src={{genesis_file}} dest=/etc/{{service}}/genesis.json owner={{service}} group={{service}}"
- name: copy tendermint config.toml
tags: reconfig-toml
when: validators == true or validators == 'true'
template:
src: config.toml.j2
dest: "/etc/{{service}}/tendermint/config.toml"
dest: "/etc/{{service}}/config.toml"
owner: "{{service}}"
group: "{{service}}"
@ -53,14 +41,12 @@
get_url: "url={{item['src']}} dest={{item['dst']}} force=yes"
with_items:
- { src: "https://raw.githubusercontent.com/tendermint/testnets/master/{{validator_network}}/{{service}}/genesis.json" , dst: "/etc/{{service}}/genesis.json" }
- { src: "https://raw.githubusercontent.com/tendermint/testnets/master/{{validator_network}}/tendermint/genesis.json" , dst: "/etc/{{service}}/tendermint/genesis.json" }
- { src: "https://raw.githubusercontent.com/tendermint/testnets/master/{{validator_network}}/tendermint/config.toml" , dst: "/etc/{{service}}/tendermint/config.toml" }
- { src: "https://raw.githubusercontent.com/tendermint/testnets/master/{{validator_network}}/config.toml" , dst: "/etc/{{service}}/config.toml" }
- name: Set validator network files permissions for non-validators
when: validators == false or validators == 'false'
file: "path={{item}} owner={{service}} group={{service}}"
with_items:
- "/etc/{{service}}/genesis.json"
- "/etc/{{service}}/tendermint/genesis.json"
- "/etc/{{service}}/tendermint/config.toml"
- "/etc/{{service}}/config.toml"

+ 34
- 16
ansible/roles/config/templates/config.toml.j2 View File

@ -4,33 +4,51 @@
proxy_app = "tcp://127.0.0.1:46658"
moniker = "{{inventory_hostname}}"
fast_sync = true
{% if service == 'tendermint' %}
db_backend = "memdb"
log_level = "mempool:error,*:debug"
{% else %}
db_backend = "leveldb"
#db_backend = "memdb"
#log_level = "mempool:error,*:debug"
log_level = "state:info,*:error"
{% endif %}
[rpc]
laddr = "tcp://0.0.0.0:46657"
#[mempool]
#recheck = false
#broadcast = false
#wal_dir = ""
{% if service == 'tendermint' %}
[mempool]
recheck = false
broadcast = false
wal_dir = ""
[consensus]
#max_block_size_txs = 10000
#create_empty_blocks = false
#timeout_propose = 10000
#skip_timeout_commit = true
#timeout_commit = 1
#wal_light = true
#block_part_size = 262144
max_block_size_txs = 10000
create_empty_blocks = false
timeout_propose = 10000
skip_timeout_commit = true
timeout_commit = 1
wal_light = true
block_part_size = 262144
create_empty_blocks_interval = 1
{% else %}
[consensus]
create_empty_blocks_interval = 1
{% endif %}
[p2p]
#max_msg_packet_payload_size=65536
#send_rate=51200000 # 50 MB/s
#recv_rate=51200000 # 50 MB/s
{% if service == 'tendermint' %}
max_msg_packet_payload_size=65536
send_rate=51200000 # 50 MB/s
recv_rate=51200000 # 50 MB/s
{% endif %}
laddr = "tcp://0.0.0.0:46656"
{% if validators == true or validators == 'true' %}
{% set comma = joiner(",") %}seeds = "{% for host in ((groups[testnet_name]|default([]))+(groups['tag_Environment_'~(testnet_name|regex_replace('-','_'))]|default([])))|difference(inventory_hostname) %}{{ comma() }}{{hostvars[host]["inventory_hostname"]}}:46656{% endfor %}"


+ 46
- 0
ansible/roles/config/templates/genesis.json.j2 View File

@ -0,0 +1,46 @@
{
"genesis_time":"{{ansible_date_time.iso8601}}",
"chain_id":"{{testnet_name}}",
"validators":
[
{% if (validators == true) or (validators == 'true') %}
{% set comma = joiner(",") %}
{% for host in (groups[testnet_name]|default([]))+(groups['tag_Environment_'~(testnet_name|regex_replace('-','_'))]|default([])) %}
{{ comma() }}
{
"pub_key": {
"data": "{{hostvars[host]["pubkey"]["data"]}}",
"type": "{{hostvars[host]["pubkey"]["type"]}}"
},
"power":10,
"name":"{{hostvars[host]["inventory_hostname"]}}"
}
{% endfor %}
{% endif %}
],
"app_hash":"",
"app_options": {
{% if app_options_file is defined %}
{% include app_options_file %}
{% endif %}
}
{% if service == 'ethermint' %}
,
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0xdeadbeefdeadbeef",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x40",
"gasLimit": "0x8000000",
"alloc": {
"0x7eff122b94897ea5b0e2a9abf47b86337fafebdc": { "balance": "10000000000000000000000000000000000" },
"0xc6713982649D9284ff56c32655a9ECcCDA78422A": { "balance": "10000000000000000000000000000000000" }
}
{% endif %}
}

+ 1
- 4
ansible/roles/generic-service/tasks/main.yml View File

@ -15,11 +15,8 @@
- name: Reload systemd services
systemd: "name={{service}} daemon_reload=yes enabled=no"
- name: Create tendermint directory
file: "path=/etc/{{service}}/tendermint state=directory mode=0755 owner={{service}} group={{service}}"
- name: Initialize tendermint
command: "/usr/bin/tendermint init --home /etc/{{service}}/tendermint"
command: "/usr/bin/tendermint init --home /etc/{{service}}"
become: yes
become_user: "{{service}}"

Loading…
Cancel
Save