---
|
|
- 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 binary
|
|
unarchive: >
|
|
src={{tendermint_download}}
|
|
dest=/usr/local/bin
|
|
remote_src=true
|
|
mode=0755
|
|
creates=/usr/local/bin/tendermint
|
|
|
|
- name: generate private validator
|
|
shell: tendermint gen_validator >> priv_validator.json
|
|
args:
|
|
chdir: "{{tendermint_home}}"
|
|
creates: priv_validator.json
|
|
|
|
- name: copy config
|
|
template: >
|
|
src=config.toml.j2
|
|
dest={{tendermint_home}}/config.toml
|
|
owner={{tendermint_user}}
|
|
group={{tendermint_group}}
|
|
mode=0644
|
|
register: config_was_copied
|
|
# notify: restart tendermint
|
|
|
|
- name: set ownership
|
|
file: >
|
|
state=directory
|
|
path={{tendermint_home}}
|
|
owner={{tendermint_user}}
|
|
group={{tendermint_group}}
|
|
recurse=yes
|
|
when: config_was_copied|changed
|
|
|
|
- name: copy upstart script
|
|
template: >
|
|
src={{tendermint_upstart_template}}
|
|
dest=/etc/init/tendermint.conf
|
|
owner=root
|
|
group=root
|
|
mode=0644
|
|
when: tendermint_use_upstart
|
|
# 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
|