Merge pull request #1 from phahulin/master
Make poa_role a separte variable
This commit is contained in:
commit
bea34b7c41
|
@ -2,3 +2,13 @@ files/*.pub
|
|||
*.retry
|
||||
group_vars/all
|
||||
hosts
|
||||
|
||||
logs/*.err
|
||||
logs/*.out
|
||||
logs/*.log
|
||||
logs/*.gz
|
||||
|
||||
logs/old/*.err
|
||||
logs/old/*.out
|
||||
logs/old/*.log
|
||||
logs/old/*.gz
|
||||
|
|
79
README.md
79
README.md
|
@ -1,5 +1,76 @@
|
|||
# poa-devops
|
||||
DevOps scripts
|
||||
## DevOps scripts
|
||||
|
||||
Prepare for run: Change variables in group_vars/all.
|
||||
How run: ansible-playbook -i hosts site.yml
|
||||
### 1. Setup blockchain backup from a node:
|
||||
1. connect to the node as `root`.
|
||||
|
||||
2. clone this repository to `root`'s home folder:
|
||||
```
|
||||
git clone https://github.com/poanetwork/poa-devops.git
|
||||
```
|
||||
|
||||
3. make sure `python` (v2.6+ or v3.5+) is installed on the node.
|
||||
|
||||
4. install `pip` and/or upgrade it to the newest version:
|
||||
```
|
||||
apt-get install python-pip
|
||||
pip install --upgrade pip
|
||||
```
|
||||
|
||||
5. upgrade `setuptools` to the newest version:
|
||||
```
|
||||
pip install --upgrade setuptools
|
||||
```
|
||||
|
||||
6. install `boto` and `boto3` packages:
|
||||
```
|
||||
pip install boto boto3
|
||||
```
|
||||
|
||||
7. install `ansible`:
|
||||
```
|
||||
pip install ansible
|
||||
```
|
||||
|
||||
8. 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`)
|
||||
* `access_key` - s3 access key
|
||||
* `secret_key` - s3 secret key
|
||||
* `s3_bucket` - s3 bucket name
|
||||
|
||||
9. create `hosts` file:
|
||||
```
|
||||
cp hosts.example hosts
|
||||
```
|
||||
and set it to run on localhost:
|
||||
```
|
||||
[backup]
|
||||
localhost
|
||||
```
|
||||
|
||||
10. run playbook (still, do this on the node)
|
||||
```
|
||||
ansible-playbook -i hosts -c local site.yml
|
||||
```
|
||||
|
||||
11. if all is well, setup a cronjob to run every hour:
|
||||
```
|
||||
crontab -e
|
||||
```
|
||||
append the following line:
|
||||
```
|
||||
30 * * * * /bin/bash /root/poa-devops/bkp-blockchain-cron.sh
|
||||
```
|
||||
|
||||
12. configure logrotate to archive old log files. Create file `/etc/cron.hourly/poa-devops-logrotate` with the following content:
|
||||
```
|
||||
#!/bin/bash
|
||||
/usr/sbin/logrotate /root/poa-devops/bkp-blockchain-logrotate.conf
|
||||
```
|
||||
and set permission to run it:
|
||||
```
|
||||
chmod 755 /etc/cron.hourly/poa-devops-logrotate
|
||||
```
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
#### line to add to crontab (remove leading '#')
|
||||
# 30 * * * * /bin/bash /root/poa-devops/bkp-blockchain-cron.sh
|
||||
####
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o
|
||||
|
||||
OUT_FILE="logs/bkp-blockchain.out"
|
||||
ERR_FILE="logs/bkp-blockchain.err"
|
||||
|
||||
cd /root/poa-devops
|
||||
|
||||
echo "Starting at $(date -u)" >> $OUT_FILE
|
||||
echo "Starting at $(date -u)" >> $ERR_FILE
|
||||
|
||||
# actual command
|
||||
/usr/local/bin/ansible-playbook -i hosts -c local site.yml >> $OUT_FILE 2>> $ERR_FILE
|
||||
|
||||
echo "" >> $OUT_FILE
|
||||
echo "" >> $ERR_FILE
|
|
@ -0,0 +1,32 @@
|
|||
/root/poa-devops/logs/*.out {
|
||||
rotate 10
|
||||
size 200M
|
||||
missingok
|
||||
compress
|
||||
copytruncate
|
||||
dateext
|
||||
dateformat %Y-%m-%d-%s
|
||||
olddir old
|
||||
}
|
||||
|
||||
/root/poa-devops/logs/*.err {
|
||||
rotate 10
|
||||
size 200M
|
||||
missingok
|
||||
compress
|
||||
copytruncate
|
||||
dateext
|
||||
dateformat %Y-%m-%d-%s
|
||||
olddir old
|
||||
}
|
||||
|
||||
/root/poa-devops/logs/*.log {
|
||||
rotate 10
|
||||
size 200M
|
||||
missingok
|
||||
compress
|
||||
copytruncate
|
||||
dateext
|
||||
dateformat %Y-%m-%d-%s
|
||||
olddir old
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
---
|
||||
poa_role: "bootnode|validator|moc|explorer|netstat"
|
||||
|
||||
#AWS Key
|
||||
access_key: "KEY_NAME"
|
||||
secret_key: "KEY_SECRET"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
- name: Create blockchain archive
|
||||
archive:
|
||||
format: gz
|
||||
path: /home/moc/parity_data
|
||||
path: /home/{{ poa_role }}/parity_data
|
||||
dest: "/data/parity_data.tar.gz"
|
||||
|
||||
- name: Upload to s3
|
||||
|
|
Loading…
Reference in New Issue