Browse Source

[ansible-tendermint] systemd template

pull/1943/head
Anton Kaliaev 8 years ago
parent
commit
649a485275
No known key found for this signature in database GPG Key ID: 7B6881D965918214
8 changed files with 50 additions and 7 deletions
  1. +5
    -0
      ansible-tendermint/README.md
  2. +4
    -0
      ansible-tendermint/defaults/main.yml
  3. +4
    -0
      ansible-tendermint/handlers/main.yml
  4. +13
    -1
      ansible-tendermint/tasks/install.yml
  5. +0
    -5
      ansible-tendermint/tasks/main.yml
  6. +6
    -0
      ansible-tendermint/tasks/start.yml
  7. +1
    -1
      ansible-tendermint/templates/tendermint.conf.j2
  8. +17
    -0
      ansible-tendermint/templates/tendermint.systemd.j2

+ 5
- 0
ansible-tendermint/README.md View File

@ -29,6 +29,10 @@ tendermint_group: tendermint
tendermint_upstart_start_on: start on runlevel [345] tendermint_upstart_start_on: start on runlevel [345]
tendermint_upstart_stop_on: stop on runlevel [!345] tendermint_upstart_stop_on: stop on runlevel [!345]
tendermint_manage_service: true tendermint_manage_service: true
tendermint_use_upstart: true
tendermint_use_systemd: false
tendermint_upstart_template: "tendermint.conf.j2"
tendermint_systemd_template: "tendermint.systemd.j2"
tendermint_home: /opt/tendermint tendermint_home: /opt/tendermint
tendermint_rpc_port: 46657 tendermint_rpc_port: 46657
@ -38,6 +42,7 @@ tendermint_log_file: /var/log/tendermint.log
tendermint_chain_id: mychain tendermint_chain_id: mychain
tendermint_genesis_time: "{{ansible_date_time.iso8601_micro}}" tendermint_genesis_time: "{{ansible_date_time.iso8601_micro}}"
tendermint_seeds: ""
``` ```
You can also change `templates/config.toml.j2` to suit your needs. You can also change `templates/config.toml.j2` to suit your needs.


+ 4
- 0
ansible-tendermint/defaults/main.yml View File

@ -11,6 +11,10 @@ tendermint_group: tendermint
tendermint_upstart_start_on: start on runlevel [345] tendermint_upstart_start_on: start on runlevel [345]
tendermint_upstart_stop_on: stop on runlevel [!345] tendermint_upstart_stop_on: stop on runlevel [!345]
tendermint_manage_service: true tendermint_manage_service: true
tendermint_use_upstart: true
tendermint_use_systemd: false
tendermint_upstart_template: "tendermint.conf.j2"
tendermint_systemd_template: "tendermint.systemd.j2"
tendermint_home: /opt/tendermint tendermint_home: /opt/tendermint
tendermint_rpc_port: 46657 tendermint_rpc_port: 46657


+ 4
- 0
ansible-tendermint/handlers/main.yml View File

@ -1,5 +1,9 @@
--- ---
- name: reload systemd
become: true
command: systemctl daemon-reload
- name: restart tendermint - name: restart tendermint
action: service name=tendermint state=restarted enabled=yes action: service name=tendermint state=restarted enabled=yes
when: tendermint_manage_service when: tendermint_manage_service

+ 13
- 1
ansible-tendermint/tasks/install.yml View File

@ -103,9 +103,21 @@
- name: copy upstart script - name: copy upstart script
template: > template: >
src=tendermint.conf.j2
src={{tendermint_upstart_template}}
dest=/etc/init/tendermint.conf dest=/etc/init/tendermint.conf
owner=root owner=root
group=root group=root
mode=0644 mode=0644
when: tendermint_use_upstart
# notify: restart tendermint # notify: restart tendermint
- name: copy systemd script
template: >
src={{tendermint_systemd_template}}
dest=/etc/systemd/system/tendermint.service
owner=root
group=root
mode=0644
when: tendermint_use_systemd
notify:
- reload systemd

+ 0
- 5
ansible-tendermint/tasks/main.yml View File

@ -5,9 +5,4 @@
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version}}.yml" - "{{ ansible_os_family }}-{{ ansible_distribution_major_version}}.yml"
- "{{ ansible_os_family }}.yml" - "{{ ansible_os_family }}.yml"
- include: install.yml - include: install.yml
- service: >
name=tendermint
state=stopped
enabled=yes
when: tendermint_manage_service
- include: start.yml - include: start.yml

+ 6
- 0
ansible-tendermint/tasks/start.yml View File

@ -18,3 +18,9 @@
shell: echo "restarting ..." shell: echo "restarting ..."
when: genesis_file_copied|changed and num_validators.stdout|int > 0 when: genesis_file_copied|changed and num_validators.stdout|int > 0
notify: restart tendermint notify: restart tendermint
- service: >
name=tendermint
state=started
enabled=yes
when: tendermint_manage_service

+ 1
- 1
ansible-tendermint/templates/tendermint.conf.j2 View File

@ -6,7 +6,7 @@ stop on {{ tendermint_upstart_stop_on }}
script script
# Use su to become tendermint user non-interactively on old Upstart versions (see http://superuser.com/a/234541/76168) # Use su to become tendermint user non-interactively on old Upstart versions (see http://superuser.com/a/234541/76168)
exec su -s /bin/sh -c 'TMROOT={{tendermint_home}} exec "$0" "$@" > {{ tendermint_log_file }} &2>1' tendermint -- /usr/local/bin/tendermint node \
exec su -s /bin/sh -c 'TMROOT={{tendermint_home}} exec "$0" "$@" >> {{ tendermint_log_file }} 2>&1' tendermint -- /usr/local/bin/tendermint node \
--moniker={{inventory_hostname}} --moniker={{inventory_hostname}}
end script end script


+ 17
- 0
ansible-tendermint/templates/tendermint.systemd.j2 View File

@ -0,0 +1,17 @@
[Unit]
Description=Tendermint
Requires=network-online.target
After=network-online.target
[Service]
Environment="TMROOT={{tendermint_home}}"
Restart=on-failure
User={{ tendermint_user }}
Group={{ tendermint_group }}
PermissionsStartOnly=true
ExecStart=/usr/local/bin/tendermint node --moniker={{inventory_hostname}}
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target

Loading…
Cancel
Save