From e448cb369a9b2813f852bf4340ed463678b22431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 16 Mar 2022 00:57:42 +0100 Subject: [PATCH] consul: add ENR address to service metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- defaults/main.yml | 1 + tasks/consul.yml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index bfc5886..3eecdcf 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -61,3 +61,4 @@ nimbus_fluffy_rpc_port: 9900 nimbus_fluffy_consul_service_name: 'nimbus-fluffy' nimbus_fluffy_consul_service_file_name: '{{ nimbus_fluffy_service_name | replace("-", "_") }}' nimbus_fluffy_consul_metrics_service_name: '{{ nimbus_fluffy_consul_service_name }}-metrics' +nimbus_fluffy_consul_url: 'http://localhost:8500/v1/catalog' diff --git a/tasks/consul.yml b/tasks/consul.yml index 8fc9a5b..b9cd1d6 100644 --- a/tasks/consul.yml +++ b/tasks/consul.yml @@ -1,4 +1,20 @@ --- +- name: Query node ENR address + uri: + url: 'http://localhost:{{ nimbus_fluffy_rpc_port }}/' + method: 'POST' + body_format: 'json' + body: + id: 1 + jsonrpc: '2.0' + method: 'discv5_nodeInfo' + params: [] + register: node_info_raw + +- name: Extract node ENR address + set_fact: + nimbus_fluffy_node_enr: '{{ node_info_raw.json.result.nodeENR }}' + - name: 'Create Consul service definition' include_role: name=consul-service vars: @@ -9,6 +25,8 @@ port: '{{ nimbus_fluffy_listening_port }}' address: '{{ nimbus_fluffy_public_address }}' tags: ['{{ env }}.{{ stage }}', 'eth1', 'nimbus'] + meta: + node_enr: '{{ nimbus_fluffy_node_enr }}' checks: - name: '{{ nimbus_fluffy_consul_service_name }}-health' type: 'script'