support running init before container creation
This allows for providing a custom genesis config file. For more details see: https://github.com/status-im/infra-nimbus/issues/53 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
8d2eeb8961
commit
27ff1d257b
|
@ -47,7 +47,7 @@ geth_websocket_port: '{{ geth_rpc_port + 1 | int }}'
|
||||||
geth_websocket_api: 'eth,net,web3,personal,admin'
|
geth_websocket_api: 'eth,net,web3,personal,admin'
|
||||||
geth_websocket_origins: 'localhost'
|
geth_websocket_origins: 'localhost'
|
||||||
|
|
||||||
# Sync mode: full, fast, light
|
# Sync mode: full, fast, light, snap
|
||||||
geth_sync_mode: 'light'
|
geth_sync_mode: 'light'
|
||||||
# Maximum number of untrusted peers that can connect
|
# Maximum number of untrusted peers that can connect
|
||||||
geth_max_peers: 50
|
geth_max_peers: 50
|
||||||
|
@ -64,6 +64,12 @@ geth_trusted_peers_file: '{{ geth_cont_vol }}/data/trusted-nodes.json'
|
||||||
# Any additional flags you want to provide
|
# Any additional flags you want to provide
|
||||||
geth_extra_flags: []
|
geth_extra_flags: []
|
||||||
|
|
||||||
|
# Some custom testnets require a custom init
|
||||||
|
geth_init_enabled: false
|
||||||
|
geth_init_genesis_path: '{{ geth_cont_vol }}/genesis.json'
|
||||||
|
#geth_init_url: ~
|
||||||
|
#geth_init_sha256: ~
|
||||||
|
|
||||||
# Custom bootnodes
|
# Custom bootnodes
|
||||||
geth_bootnodes: []
|
geth_bootnodes: []
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
docker_container:
|
docker_container:
|
||||||
name: '{{ geth_cont_name }}'
|
name: '{{ geth_cont_name }}'
|
||||||
image: '{{ geth_cont_image }}'
|
image: '{{ geth_cont_image }}'
|
||||||
|
detach: false
|
||||||
pull: true
|
pull: true
|
||||||
auto_remove: yes
|
auto_remove: yes
|
||||||
command: |
|
command: |
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
---
|
||||||
|
- name: Download genesis config file
|
||||||
|
get_url:
|
||||||
|
url: '{{ geth_init_url | mandatory }}'
|
||||||
|
dest: '{{ geth_init_genesis_path | mandatory }}'
|
||||||
|
checksum: 'sha256: {{ geth_init_sha256 | mandatory }}'
|
||||||
|
owner: dockremap
|
||||||
|
group: docker
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: Check if chaindata was created
|
||||||
|
stat:
|
||||||
|
path: '{{ geth_cont_vol }}/data/geth/chaindata'
|
||||||
|
register: geth_chaindata_dir_before
|
||||||
|
|
||||||
|
- name: Initialize network definition
|
||||||
|
when: not geth_chaindata_dir_before.stat.exists
|
||||||
|
block:
|
||||||
|
- name: Run init command with config
|
||||||
|
docker_container:
|
||||||
|
name: '{{ geth_cont_name }}-init'
|
||||||
|
image: '{{ geth_cont_image }}'
|
||||||
|
user: root
|
||||||
|
detach: false
|
||||||
|
auto_remove: true
|
||||||
|
volumes:
|
||||||
|
- '{{ geth_cont_vol }}/keys:/keys:rw'
|
||||||
|
- '{{ geth_cont_vol }}/data:/data:rw'
|
||||||
|
- '{{ geth_init_genesis_path }}:/genesis.json:rw'
|
||||||
|
command: |
|
||||||
|
{{ geth_extra_flags | join(" ") }} --datadir=/data init /genesis.json
|
||||||
|
|
||||||
|
- name: Check if chaindata was created
|
||||||
|
stat:
|
||||||
|
path: '{{ geth_cont_vol }}/data/geth/chaindata'
|
||||||
|
register: geth_chaindata_dir_after
|
||||||
|
|
||||||
|
- name: Verify chaindata folder was created
|
||||||
|
assert:
|
||||||
|
that: '{{ geth_chaindata_dir_after.stat.exists }}'
|
||||||
|
fail_msg: 'Failed to init node genesis state!'
|
||||||
|
quiet: true
|
|
@ -2,6 +2,8 @@
|
||||||
- import_tasks: checks.yml
|
- import_tasks: checks.yml
|
||||||
- import_tasks: generate.yml
|
- import_tasks: generate.yml
|
||||||
- import_tasks: trusted_peers.yml
|
- import_tasks: trusted_peers.yml
|
||||||
|
- import_tasks: init.yml
|
||||||
|
when: geth_init_enabled
|
||||||
- import_tasks: container.yml
|
- import_tasks: container.yml
|
||||||
- import_tasks: firewall.yml
|
- import_tasks: firewall.yml
|
||||||
- import_tasks: wrappers.yml
|
- import_tasks: wrappers.yml
|
||||||
|
|
Loading…
Reference in New Issue