Merge pull request #2 from phahulin/master

Add role to perform spec.json hard-forks
This commit is contained in:
phahulin 2018-01-08 22:46:48 +03:00 committed by GitHub
commit 789d3a1dd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 102 additions and 4 deletions

View File

@ -39,13 +39,15 @@ and set the following variables:
* `poa_role` - node's role (one of `bootnode`, `validator`, `moc`, `explorer`, `netstat`)
* `access_key` - s3 access key
* `secret_key` - s3 secret key
* `s3_bucket` - s3 bucket name
* `s3_bucket` - s3 bucket name
you can ignore other variables in this file
9. create `hosts` file:
```
cp hosts.example hosts
touch hosts
```
and set it to run on localhost:
and set it to run `backup` on localhost:
```
[backup]
localhost
@ -74,3 +76,60 @@ and set permission to run it:
```
chmod 755 /etc/cron.hourly/poa-devops-logrotate
```
### 2. Make a spec.json hard-fork
0. this guide assumes that you're running this playbook from the same machine you used to make initial deployment of your node. So that you already have `python` and `ansible` installed, and you have the correct ssh keypair to root-access the node.
1. clone this repository:
```
git clone https://github.com/poanetwork/poa-devops.git
cd poa-devops
```
2. create `group_vars/all` file:
```
cp group_vars/all.example group_vars/all
```
and set the following variables:
* `poa_role` - node's role (one of `bootnode`, `validator`, `moc`, `explorer`, `netstat`)
* `MAIN_REPO_FETCH` - github account where spec.json is located (e.g. "poanetwork")
* `GENESIS_BRANCH` - correct branch name to fetch from (e.g. "sokol" for testnet, "core" for mainnet)
ignore other variables in this file
3. create `hosts` file:
```
touch hosts
```
and put your node's ip address (assuming it's 192.0.2.1) there with the following header:
```
[hf-spec-change]
192.0.2.1
```
4. run the playbook:
```
ansible-playbook -i hosts site.yml
```
5. verify that your node is active in the netstat of the corresponding network
6. connect to the node
```
ssh root@192.0.2.1
```
switch to the home folder of corresponding role:
```
# substitute validator with your node's role (bootnode, moc, ...)
cd /home/validator
```
and check the update time of `spec.json` (should be about the time you started the playbook)
```
ls -lh
# a long list should appear here, look for spec.json in the rightmost column and check the date and time on the same row
```
also check that backup was created:
```
ls -lh spec-hfs/
# look for a file named similar to spec-hf-20180108-174649.json Numbers represent date and time in UTC when the playbook was started
```

View File

@ -6,3 +6,7 @@ access_key: "KEY_NAME"
secret_key: "KEY_SECRET"
s3_bucket: "BUCKET_NAME"
#For HFs
MAIN_REPO_FETCH: "poanetwork"
GENESIS_BRANCH: "sokol"

View File

@ -1,2 +1,5 @@
[backup]
INSERT_HERE_SERVERS_HOSTNAME_OR_IPs
[hf-spec-change]
INSERT_HERE_SERVERS_HOSTNAME_OR_IPs

View File

@ -0,0 +1,23 @@
---
- name: Shutdown poa-netstats service
service: name=poa-netstats state=stopped
- name: Shutdown poa-parity service
service: name=poa-parity state=stopped
- name: Create directory for spec backups
file: path={{ home }}/spec-hfs state=directory
- name: Create previous spec backup
command: cp {{ home }}/spec.json {{ home }}/spec-hfs/spec-hf-{{ date }}.json
- name: Download new spec
get_url: url={{ item }} dest={{ home }}/ mode=0644
with_items:
- "https://raw.githubusercontent.com/{{ MAIN_REPO_FETCH }}/poa-chain-spec/{{ GENESIS_BRANCH }}/spec.json"
- name: Launch poa-parity service
service: name=poa-parity state=started
- name: Launch poa-netstats service
service: name=poa-netstats state=started

View File

@ -1,7 +1,16 @@
- hosts: backup
vars:
date: "{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}"
date: "{{ lookup('pipe', 'date -u +%Y%m%d-%H%M%S') }}"
user: root
roles:
- backup-parity
tags: backup
- hosts: hf-spec-change
vars:
date: "{{ lookup('pipe', 'date -u +%Y%m%d-%H%M%S') }}"
home: "/home/{{ poa_role }}"
user: root
roles:
- hf-spec-change
tags: hf-spec