From 4aff2d15b84e8b25c32e72492062b8c5bc60e30b Mon Sep 17 00:00:00 2001 From: phahulin Date: Mon, 5 Feb 2018 23:49:21 +0300 Subject: [PATCH] Add playbook and docs on Set-min-gas-price --- README.md | 3 +- docs/Set-min-gas-price.md | 59 ++++++++++++++++++++++++++ roles/set-min-gas-price/tasks/main.yml | 19 +++++++++ set-min-gas-price.yml | 9 ++++ 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 docs/Set-min-gas-price.md create mode 100644 roles/set-min-gas-price/tasks/main.yml create mode 100644 set-min-gas-price.yml diff --git a/README.md b/README.md index 813ae3d..9fc2ba0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ ## DevOps scripts -1. [Setup blockchain backup from a node](./docs/Blockchain-backup.md) +1. [Setup blockchain backup on a node](./docs/Blockchain-backup.md) 2. [Make a spec.json hard-fork](./docs/Spec-hardfork.md) 3. [Update scripts for validator nodes](./docs/Update-scripts-validator.md) +4. [Set min_gas_price for validator nodes](./docs/Set-min-gas-price.md) diff --git a/docs/Set-min-gas-price.md b/docs/Set-min-gas-price.md new file mode 100644 index 0000000..37e6c67 --- /dev/null +++ b/docs/Set-min-gas-price.md @@ -0,0 +1,59 @@ +## Update scripts on validator nodes + +**ONLY FOR VALIDATOR NODES** + +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 if you haven't done so before +``` +git clone https://github.com/poanetwork/poa-devops.git +cd poa-devops +``` +or pull the latest changes +``` +cd poa-devops +git pull origin master +``` + +2. create/edit `hosts` file: +``` +echo "" > hosts +``` +and put your node's ip address (assuming it's 192.0.2.1) there with the following header: +``` +[set-min-gas-price] +192.0.2.1 +``` +**NOTE**: if you're updating an existing file, make sure you remove other tags `[...]` and ips. + +4. run the playbook: +``` +ansible-playbook -i hosts set-min-gas-price.yml +``` + +5. connect to the node +``` +ssh root@192.0.2.1 +``` +switch to the home folder: +``` +cd /home/validator +``` +and check the update time of `node.toml` file (should be about the time you started the playbook) +``` +ls -lh +# a long list should appear here, look for node.toml in the rightmost column and check the date and time on the same row +``` +then check that line was actually added to the file: +``` +grep min_gas_price node.toml +``` +should return a **single** line: +``` +min_gas_price = 1000000000 +``` +also check that backup was created: +``` +ls -lh backups-node.toml/ +# look for a file named similar to node.toml-20180202-184912 Numbers represent date and time in UTC when the playbook was started +``` diff --git a/roles/set-min-gas-price/tasks/main.yml b/roles/set-min-gas-price/tasks/main.yml new file mode 100644 index 0000000..0400b26 --- /dev/null +++ b/roles/set-min-gas-price/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: Create directory for backups + file: path={{ home }}/backups-node.toml state=directory + +- name: Backup existing version + command: cp -a {{ home }}/node.toml {{ home }}/backups-node.toml/node.toml-{{ date }} + +- name: Add min_gas_price to node.toml + lineinfile: + path: "{{ home }}/node.toml" + insertafter: '^\[mining\]' + line: "min_gas_price = 1000000000" + state: present + +- name: Restart poa-parity service + service: name=poa-parity state=restarted enabled=yes + +- name: Restart poa-netstats service + service: name=poa-netstats state=restarted enabled=yes diff --git a/set-min-gas-price.yml b/set-min-gas-price.yml new file mode 100644 index 0000000..e1c1784 --- /dev/null +++ b/set-min-gas-price.yml @@ -0,0 +1,9 @@ +- hosts: set-min-gas-price + vars: + poa_role: validator + username: validator + date: "{{ lookup('pipe', 'date -u +%Y%m%d-%H%M%S') }}" + home: "/home/{{ poa_role }}" + user: root + roles: + - set-min-gas-price