Browse Source

Fixed templates to run on AWS, added option to install tendermint with dummy app

pull/1943/head
Greg Szabo 7 years ago
parent
commit
55c0a79aa6
6 changed files with 50 additions and 2 deletions
  1. +2
    -0
      ansible/install.yml
  2. +1
    -1
      ansible/roles/config/templates/config.toml.j2
  3. +1
    -1
      ansible/roles/config/templates/genesis-server.json.j2
  4. +11
    -0
      ansible/roles/generic-service-config/tasks/main.yml
  5. +17
    -0
      ansible/roles/generic-service-prepare/tasks/main.yml
  6. +18
    -0
      ansible/roles/generic-service-prepare/templates/systemd.service.j2

+ 2
- 0
ansible/install.yml View File

@ -5,6 +5,8 @@
- hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}:tag_Environment_{{ lookup('env','TF_VAR_TESTNET_NAME') }}" - hosts: "{{ lookup('env','TF_VAR_TESTNET_NAME') }}:tag_Environment_{{ lookup('env','TF_VAR_TESTNET_NAME') }}"
roles: roles:
- install - install
- {role: generic-service-prepare, when: service == 'tendermint'}
- {role: config, testnet_name: "{{lookup('env','TF_VAR_TESTNET_NAME')}}"} - {role: config, testnet_name: "{{lookup('env','TF_VAR_TESTNET_NAME')}}"}
- {role: generic-service-config, when: service == 'tendermint'}
- start - start

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

@ -13,7 +13,7 @@ laddr = "tcp://0.0.0.0:46657"
[p2p] [p2p]
laddr = "tcp://0.0.0.0:46656" laddr = "tcp://0.0.0.0:46656"
{% if validators == true %} {% if validators == true %}
{% set comma = joiner(",") %}seeds = "{% for host in groups[testnet_name]|difference(inventory_hostname) %}{{ comma() }}{{hostvars[host]["inventory_hostname"]}}:46656{% endfor %}"
{% set comma = joiner(",") %}seeds = "{% for host in ((groups[testnet_name]|default([]))+(groups['tag_Environment_'~testnet_name]|default([])))|difference(inventory_hostname) %}{{ comma() }}{{hostvars[host]["inventory_hostname"]}}:46656{% endfor %}"
{% else %} {% else %}
seeds = "{{ seeds | default() }}" seeds = "{{ seeds | default() }}"
{% endif %} {% endif %}

+ 1
- 1
ansible/roles/config/templates/genesis-server.json.j2 View File

@ -5,7 +5,7 @@
[ [
{% if validators == true %} {% if validators == true %}
{% set comma = joiner(",") %} {% set comma = joiner(",") %}
{% for host in groups[testnet_name] %}
{% for host in (groups[testnet_name]|default([]))+(groups['tag_Environment_'~testnet_name]|default([])) %}
{{ comma() }} {{ comma() }}
{ {
"pub_key": { "pub_key": {


+ 11
- 0
ansible/roles/generic-service-config/tasks/main.yml View File

@ -0,0 +1,11 @@
---
- name: here
file: "path=/etc/{{service}}/tendermint state=absent"
- 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"
become: yes
become_user: "{{service}}"

+ 17
- 0
ansible/roles/generic-service-prepare/tasks/main.yml View File

@ -0,0 +1,17 @@
---
- name: Create service group
group: "name={{service}}"
- name: Create service user
user: "name={{service}} group={{service}} home=/etc/{{service}}"
- name: Change user folder to more permissive
file: "path=/etc/{{service}} mode=0755"
- name: Create tendermint service
template: "src=systemd.service.j2 dest=/etc/systemd/system/{{service}}.service"
- name: Reload systemd services
systemd: "name={{service}} daemon_reload=yes enabled=no"

+ 18
- 0
ansible/roles/generic-service-prepare/templates/systemd.service.j2 View File

@ -0,0 +1,18 @@
[Unit]
Description={{service}} server
Requires=network-online.target
After=network-online.target
[Service]
Environment="TMHOME=/etc/{{service}}/tendermint"
Restart=on-failure
User={{service}}
Group={{service}}
PermissionsStartOnly=true
ExecStart=/usr/bin/tendermint node{{(service=='tendermint')|ternary(' --proxy_app=dummy','')}}
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM
[Install]
WantedBy=multi-user.target

Loading…
Cancel
Save