Skip to content

Commit

Permalink
Migrate snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
fewensa committed Jul 26, 2024
1 parent 0b80d78 commit 730f453
Show file tree
Hide file tree
Showing 17 changed files with 716 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Build docker image

on:
push:
branches: [main]
# push:
# branches: [main]
workflow_dispatch:

env:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Snapshots

on:
schedule:
- cron: "0 0 */2 * *"
workflow_dispatch:

jobs:
generate-snapshots:
name: Generate snapshot
runs-on: ubuntu-latest
strategy:
matrix:
playbook:
- snapshots_crab
- snapshots_darwinia
steps:
- uses: actions/checkout@v2

- name: Run playbook
uses: dawidd6/action-ansible-playbook@v2
with:
playbook: ansible/playbooks/${{ matrix.playbook }}/playbook.yml
key: "${{ secrets.SSH_PRIVATE_KEY }}"
options: --user ansible --verbose --diff
9 changes: 9 additions & 0 deletions ansible/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
3 changes: 3 additions & 0 deletions ansible/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.retry
.DS_Store
*.local.*
1 change: 1 addition & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# ansible-playbooks
16 changes: 16 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[defaults]
inventory = inventories/hosts.ini
roles_path = ~/.ansible/roles:./roles

stdout_callback = debug
callbacks_enabled = profile_tasks

force_color = 1
host_key_checking = False
hash_behaviour = merge

[privilege_escalation]
become = True

[connection]
pipelining = True
6 changes: 6 additions & 0 deletions ansible/inventories/hosts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[crab_nodes]
g1.crab2.darwinia.network

[darwinia_nodes]
g1.darwinia2.darwinia.network

17 changes: 17 additions & 0 deletions ansible/playbooks/_essentials/tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

- name: Install essentials packages
tags:
- apt
apt:
name: "{{ item }}"
state: present
cache_valid_time: 3600
update_cache: true
loop:
- curl
- nload
- unzip # required by unarchive module
- gnupg # required by apt_repository module
- parted # required by parted module
- zstd # required by unarchive module (.tar.zst files)
- jq
5 changes: 5 additions & 0 deletions ansible/playbooks/essentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- hosts: all:!skip_essentials
gather_facts: false
tasks:
- include_tasks: _essentials/tools.yml

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


snapshots:
gcp_project: darwinia2
gcp_snapshots_source_disk: crab-g1-data
gcp_snapshots_zone: asia-southeast1-c
gcp_snapshots_name: snapshots-crab-g1
gcp_snapshots_storage_location: asia-southeast1

chain_name: crab2
data_path: crab2/data
mounted_device: /dev/sdc
work_server: crab-g1
snapshots_workdir: /mnt/snapshots
bucket_name: snapshots.crab.network
website_title: "Crab Network Snapshots"
3 changes: 3 additions & 0 deletions ansible/playbooks/snapshots_crab/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- hosts: g1.crab2.darwinia.network
roles:
- snapshots
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


snapshots:
gcp_project: darwinia2
gcp_snapshots_source_disk: darwinia-g1-data
gcp_snapshots_zone: asia-southeast1-c
gcp_snapshots_name: snapshots-darwinia-g1
gcp_snapshots_storage_location: asia-southeast1

chain_name: darwinia2
data_path: darwinia2/data
mounted_device: /dev/sdc
work_server: darwinia-g1
snapshots_workdir: /mnt/snapshots
bucket_name: snapshots.darwinia.network
website_title: "Darwinia Network Snapshots"
3 changes: 3 additions & 0 deletions ansible/playbooks/snapshots_darwinia/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- hosts: g1.darwinia2.darwinia.network
roles:
- snapshots
20 changes: 20 additions & 0 deletions ansible/roles/snapshots/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

snapshots:
workdir: /tmp/node_snapshots

gcp_project: darwinia2
gcp_snapshots_source_disk: pangolin-g2-data
gcp_snapshots_zone: europe-west4-c
gcp_snapshots_name: snapshots-pangolin-g2
gcp_snapshots_storage_location: europe-west4

chain_name: pangolin2
chain_node_rpc: http://127.0.0.1:9944
data_path: pangolin2/data
mounted_device: /dev/sdc
work_server: pangolin-g2
snapshots_workdir: /mnt/snapshots
bucket_name: snapshots.crab.network
website_title: "Pangolin Network Snapshots"

gomplate_version: v3.11.4
Loading

0 comments on commit 730f453

Please sign in to comment.