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'