Skip to content

Commit

Permalink
Merge PR #1821: Added seed node update scripts
Browse files Browse the repository at this point in the history
* Added seed node update scripts
* Updated PENDING
* Fixed issue with GENESISFILE and added GENESISURL to seed node scripts
* Fixed unsafe reset bug
* As requested, multiline ansible-playbook command
* Added monitoring gaiacli.service to logz.io template
* Added journald configuration ansible script
  • Loading branch information
greg-szabo authored and cwgoes committed Aug 1, 2018
1 parent 840d915 commit 179b8f9
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 2 deletions.
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ FEATURES
* [cosmos-sdk-cli] Added support for cosmos-sdk-cli tool under cosmos-sdk/cmd
* This allows SDK users to initialize a new project repository.
* [tests] Remotenet commands for AWS (awsnet)
* [networks] Added ansible scripts to upgrade seed nodes on a network
* [store] Add transient store
* [gov] Add slashing for validators who do not vote on a proposal
* [cli] added `gov query-proposals` command to CLI. Can filter by `depositer`, `voter`, and `status`
Expand Down
20 changes: 19 additions & 1 deletion networks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ REGION_LIMIT?=1

# Path to gaiad for deployment. Must be a Linux binary.
BINARY?=$(CURDIR)/../build/gaiad
GAIACLI_BINARY?=$(CURDIR)/../build/gaiacli

# Path to the genesis.json and config.toml files to deploy on full nodes.
GENESISFILE?=$(CURDIR)/../build/genesis.json
Expand All @@ -39,7 +40,15 @@ disclaimer:
extract-config: disclaimer
#Make sure you have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY or your IAM roles set for AWS API access.
@if ! [ -f $(HOME)/.ssh/id_rsa.pub ]; then ssh-keygen ; fi
cd remote/ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ec2.py -l "tag_Environment_$(CLUSTER_NAME)" -u centos -b -e TESTNET_NAME="$(TESTNET_NAME)" -e GENESISFILE="$(GENESISFILE)" -e CONFIGFILE="$(CONFIGFILE)" extract-config.yml
cd remote/ansible && \
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook \
-i inventory/ec2.py \
-l "tag_Environment_$(CLUSTER_NAME)" \
-b -u centos \
-e TESTNET_NAME="$(TESTNET_NAME)" \
-e GENESISFILE="$(GENESISFILE)" \
-e CONFIGFILE="$(CONFIGFILE)" \
extract-config.yml


########################################
Expand Down Expand Up @@ -91,6 +100,15 @@ upgrade-gaiad: disclaimer
@if [ -z "`file $(BINARY) | grep 'ELF 64-bit'`" ]; then echo "Please build a linux binary using 'make build-linux'." ; false ; fi
cd remote/ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ec2.py -l "tag_Environment_$(CLUSTER_NAME)" -u centos -b -e BINARY=$(BINARY) upgrade-gaiad.yml

UNSAFE_RESET_ALL?=no
upgrade-seeds: disclaimer
#Make sure you have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY or your IAM roles set for AWS API access.
@if ! [ -f $(HOME)/.ssh/id_rsa.pub ]; then ssh-keygen ; fi
@if [ -z "`file $(BINARY) | grep 'ELF 64-bit'`" ]; then echo "Please build a linux binary using 'make build-linux'." ; false ; fi
@if [ -z "`file $(GAIACLI_BINARY) | grep 'ELF 64-bit'`" ]; then echo "Please build a linux binary using 'make build-linux'." ; false ; fi
cd remote/ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ec2.py -l "tag_Environment_$(CLUSTER_NAME)" -u centos -b -e BINARY=$(BINARY) -e GAIACLI_BINARY=$(GAIACLI_BINARY) -e UNSAFE_RESET_ALL=$(UNSAFE_RESET_ALL) upgrade-gaia.yml


list:
remote/ansible/inventory/ec2.py | python -c 'import json,sys ; print "\n".join(json.loads("".join(sys.stdin.readlines()))["tag_Environment_$(CLUSTER_NAME)"])'

Expand Down
8 changes: 8 additions & 0 deletions networks/remote/ansible/add-lcd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

- hosts: all
any_errors_fatal: true
gather_facts: no
roles:
- add-lcd

4 changes: 4 additions & 0 deletions networks/remote/ansible/roles/add-lcd/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---

GAIAD_ADDRESS: tcp://0.0.0.0:1317

9 changes: 9 additions & 0 deletions networks/remote/ansible/roles/add-lcd/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

- name: systemctl
systemd: name=gaiacli enabled=yes daemon_reload=yes

- name: restart gaiacli
service: name=gaiacli state=restarted


15 changes: 15 additions & 0 deletions networks/remote/ansible/roles/add-lcd/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---

- name: Copy binary
copy:
src: "{{GAIACLI_BINARY}}"
dest: /usr/bin
mode: 0755
notify: restart gaiacli

- name: Copy service
template:
src: gaiacli.service.j2
dest: /etc/systemd/system/gaiacli.service
notify: systemctl

17 changes: 17 additions & 0 deletions networks/remote/ansible/roles/add-lcd/templates/gaiacli.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=gaiacli
Requires=network-online.target
After=network-online.target

[Service]
Restart=on-failure
User=gaiad
Group=gaiad
PermissionsStartOnly=true
ExecStart=/usr/bin/gaiacli advanced rest-server --laddr {{GAIAD_ADDRESS}}
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM

[Install]
WantedBy=multi-user.target

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ journalbeat:
#move_metadata_to_field: ""

# Specific units to monitor.
units: ["{{service}}.service"]
units: ["{{service}}.service","gaiacli.service"]

# Specify Journal paths to open. You can pass an array of paths to Systemd Journal paths.
# If you want to open Journal from directory just pass an array consisting of one element
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

- name: restart journald
service: name=systemd-journald state=restarted


20 changes: 20 additions & 0 deletions networks/remote/ansible/roles/setup-journald/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---

- name: Disable journald rate-limiting
lineinfile: "dest=/etc/systemd/journald.conf regexp={{item.regexp}} line='{{item.line}}'"
with_items:
- { regexp: "^#RateLimitInterval", line: "RateLimitInterval=0s" }
- { regexp: "^#RateLimitBurst", line: "RateLimitBurst=0" }
notify: restart journald

- name: Create journal directory for permanent logs
file: path=/var/log/journal state=directory
notify: restart journald

- name: Set journal folder with systemd-tmpfiles
command: "systemd-tmpfiles --create --prefix /var/log/journal"
notify: restart journald

#- name: Ability to get the core dump on SIGABRT
# shell: "ulimit -c unlimited"

20 changes: 20 additions & 0 deletions networks/remote/ansible/roles/upgrade-gaiad/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,23 @@
mode: 0755
notify: restart gaiad

- name: Copy new genesis.json file, if available
when: "GENESISFILE is defined and GENESISFILE != ''"
copy:
src: "{{GENESISFILE}}"
dest: /home/gaiad/.gaiad/config/genesis.json
notify: restart gaiad

- name: Download genesis.json URL, if available
when: "GENESISURL is defined and GENESISURL != ''"
get_url:
url: "{{GENESISURL}}"
dest: /home/gaiad/.gaiad/config/genesis.json
force: yes
notify: restart gaiad

- name: Reset network
when: UNSAFE_RESET_ALL | default(false) | bool
command: "sudo -u gaiad gaiad unsafe_reset_all"
notify: restart gaiad

8 changes: 8 additions & 0 deletions networks/remote/ansible/setup-journald.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

- hosts: all
any_errors_fatal: true
gather_facts: no
roles:
- setup-journald

9 changes: 9 additions & 0 deletions networks/remote/ansible/upgrade-gaia.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

- hosts: all
any_errors_fatal: true
gather_facts: no
roles:
- upgrade-gaiad
- add-lcd

3 changes: 3 additions & 0 deletions networks/remote/ansible/upgrade-gaiad.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---

# Required: BINARY
# Optional: GENESISFILE, UNSAFE_RESET_ALL

- hosts: all
any_errors_fatal: true
gather_facts: no
Expand Down

0 comments on commit 179b8f9

Please sign in to comment.