From 992c8a43a45e06bb1f43f6c440fa03c157422f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 28 Jun 2021 13:54:08 +0200 Subject: [PATCH] rafactor to make use of infra-role-dist-validators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way we can handle hosts with multiple nodes in different folders. Signed-off-by: Jakub SokoĊ‚owski --- defaults/main.yml | 8 ++++++++ handlers/main.yml | 2 +- tasks/checks.yml | 5 ++++- tasks/main.yml | 2 ++ tasks/validators.yml | 18 ++++++++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tasks/validators.yml diff --git a/defaults/main.yml b/defaults/main.yml index 3e0f99d..25ce287 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,6 +18,14 @@ beacon_node_cont_update_enabled: true # Subfolders for separate read-only mounting beacon_node_secrets_path: '{{ beacon_node_cont_vol }}/data/{{ beacon_node_data_folder }}/secrets' +# Automatically distribute validators +beacon_node_dist_validators_enabled: false +beacon_node_dist_validators_name: '{{ beacon_node_network }}_deposits' +beacon_node_dist_validators_data_path: '{{ beacon_node_cont_vol }}/data/{{ beacon_node_data_folder }}' +#beacon_node_dist_validators_name: ~ +#beacon_node_dist_validators_start: ~ +#beacon_node_dist_validators_end: ~ + # connectivity settings beacon_node_discovery_port: 9000 beacon_node_listening_port: 9000 diff --git a/handlers/main.yml b/handlers/main.yml index bd6da46..d5b267a 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,3 @@ --- - name: Save iptables rules - shell: iptables-save > /etc/iptables/rules.v4 + shell: 'iptables-save > /etc/iptables/rules.v4' diff --git a/tasks/checks.yml b/tasks/checks.yml index 9689aa5..f97752e 100644 --- a/tasks/checks.yml +++ b/tasks/checks.yml @@ -10,4 +10,7 @@ - name: Verify network name assert: that: '{{ beacon_node_network in beacon_node_valid_network_names }}' - + quiet: true + fail_msg: | + Provided network name does not match any of expected values. + Expected: {{ beacon_node_valid_network_names | join(", ") }}' diff --git a/tasks/main.yml b/tasks/main.yml index 79a0068..952ddec 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,5 +3,7 @@ - import_tasks: install.yml - import_tasks: config.yml - import_tasks: container.yml +- import_tasks: validators.yml + when: beacon_node_dist_validators_enabled - import_tasks: firewall.yml - import_tasks: consul.yml diff --git a/tasks/validators.yml b/tasks/validators.yml new file mode 100644 index 0000000..bb11cd0 --- /dev/null +++ b/tasks/validators.yml @@ -0,0 +1,18 @@ +--- +- name: 'Distribute validators and secrets' + include_role: name=infra-role-dist-validators + vars: + dist_validators_name: '{{ beacon_node_dist_validators_name }}' + dist_validators_start: '{{ beacon_node_dist_validators_start | mandatory }}' + dist_validators_end: '{{ beacon_node_dist_validators_end | mandatory }}' + dist_validators_data_path: '{{ beacon_node_dist_validators_data_path | mandatory }}' + +- when: dist_validators_deployed is defined + block: + - name: 'Show number of validators deployed' + debug: msg='Deployed {{ dist_validators_deployed|length }} validators' + + - name: 'Restart beacon node container' + command: 'docker-compose restart' + args: + chdir: '{{ beacon_node_cont_vol }}'