From c8fa895f982744f82c18abe914693d919bf995cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 3 Jun 2022 12:01:44 +0200 Subject: [PATCH] get-geth-api-urls: query for OpenEthereum nodes too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/status-im/infra-nimbus/issues/80 Signed-off-by: Jakub SokoĊ‚owski --- ansible/requirements.yml | 4 ++-- .../roles/get-geth-api-urls/defaults/main.yml | 5 ++++- .../get-geth-api-urls/tasks/consul/posix.yml | 15 +++++++++++++-- .../get-geth-api-urls/tasks/consul/windows.yml | 16 ++++++++++++++-- ansible/roles/get-geth-api-urls/tasks/main.yml | 17 ++++++----------- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/ansible/requirements.yml b/ansible/requirements.yml index 48c6161..1f0c961 100644 --- a/ansible/requirements.yml +++ b/ansible/requirements.yml @@ -111,7 +111,7 @@ - name: infra-role-geth src: git@github.com:status-im/infra-role-geth.git - version: 3de59d6ae76b69291905d16c264a1d11a5e2e955 + version: 11cdfe59ff57faaa33ed0b6d98414ece8862b20d scm: git - name: infra-role-geth-exporter @@ -121,5 +121,5 @@ - name: infra-role-openethereum src: git@github.com:status-im/infra-role-openethereum.git - version: 83996de847c3573c1957d563782921cb24c79971 + version: 4e8fb26533ae97924dec258e158119aa4d3edf0f scm: git diff --git a/ansible/roles/get-geth-api-urls/defaults/main.yml b/ansible/roles/get-geth-api-urls/defaults/main.yml index 74e77c0..e42efe8 100644 --- a/ansible/roles/get-geth-api-urls/defaults/main.yml +++ b/ansible/roles/get-geth-api-urls/defaults/main.yml @@ -6,7 +6,10 @@ eth2_to_eth1_map: eth2_network_name: '{{ beacon_node_network | mandatory }}' eth1_network_name: '{{ eth2_to_eth1_map[eth2_network_name] | mandatory }}' -geth_node_api_consul_name: 'nimbus-{{ eth1_network_name | mandatory }}-node' +geth_node_api_consul_names: + - 'geth-{{ eth1_network_name | mandatory }}' + - 'openeth-{{ eth1_network_name | mandatory }}' +geth_api_addresses: [] # The more the merrier, since we don't want to hit Infura throttling. infura_api_tokens: - '9e2f2cc13f70432f8b87dbe7d51b81db' diff --git a/ansible/roles/get-geth-api-urls/tasks/consul/posix.yml b/ansible/roles/get-geth-api-urls/tasks/consul/posix.yml index 71c12c9..ab9a5f5 100644 --- a/ansible/roles/get-geth-api-urls/tasks/consul/posix.yml +++ b/ansible/roles/get-geth-api-urls/tasks/consul/posix.yml @@ -6,12 +6,23 @@ - name: Find available Geth API RPC services uri: - url: '{{ consul_catalog_url }}/service/{{ geth_node_api_consul_name }}-rpc?dc={{ item }}' + url: '{{ consul_catalog_url }}/service/{{ service_name }}-rpc?dc={{ item }}' with_items: '{{ data_centers.json }}' register: geth_rpc_services - name: Find available Geth API WebSocket services uri: - url: '{{ consul_catalog_url }}/service/{{ geth_node_api_consul_name }}-ws?dc={{ item }}' + url: '{{ consul_catalog_url }}/service/{{ service_name }}-ws?dc={{ item }}' with_items: '{{ data_centers.json }}' register: geth_ws_services + +# On Windows json attribute is missing when it's []. +- name: Extract Geth websocket IP and port + set_fact: + geth_api_addresses: | + {{ geth_api_addresses + + (geth_rpc_services.results + + geth_ws_services.results) + | sum(attribute="json", start=[]) + | map(attribute='ServiceMeta.url') + | list }} diff --git a/ansible/roles/get-geth-api-urls/tasks/consul/windows.yml b/ansible/roles/get-geth-api-urls/tasks/consul/windows.yml index a825d03..8cd79fb 100644 --- a/ansible/roles/get-geth-api-urls/tasks/consul/windows.yml +++ b/ansible/roles/get-geth-api-urls/tasks/consul/windows.yml @@ -8,7 +8,7 @@ - name: Find available Geth API RPC services win_uri: - url: '{{ consul_catalog_url }}/service/{{ geth_node_api_consul_name }}-rpc?dc={{ item }}' + url: '{{ consul_catalog_url }}/service/{{ service_name }}-rpc?dc={{ item }}' content_type: 'application/json' return_content: true with_items: '{{ data_centers.json }}' @@ -16,8 +16,20 @@ - name: Find available Geth WebSocket services win_uri: - url: '{{ consul_catalog_url }}/service/{{ geth_node_api_consul_name }}-ws?dc={{ item }}' + url: '{{ consul_catalog_url }}/service/{{ service_name }}-ws?dc={{ item }}' content_type: 'application/json' return_content: true with_items: '{{ data_centers.json }}' register: geth_ws_services + +# On Windows json attribute is missing when it's []. +- name: Extract Geth websocket IP and port + set_fact: + geth_api_addresses: | + {{ geth_api_addresses + + (geth_rpc_services.results + + geth_ws_services.results) + | selectattr("json", "defined") + | sum(attribute="json", start=[]) + | map(attribute='ServiceMeta.url') + | list }} diff --git a/ansible/roles/get-geth-api-urls/tasks/main.yml b/ansible/roles/get-geth-api-urls/tasks/main.yml index a8c9a05..84d7a4c 100644 --- a/ansible/roles/get-geth-api-urls/tasks/main.yml +++ b/ansible/roles/get-geth-api-urls/tasks/main.yml @@ -1,20 +1,15 @@ --- - include_tasks: consul/posix.yml when: ansible_system in ['Linux', 'Darwin'] + loop: '{{ geth_node_api_consul_names }}' + loop_control: + loop_var: 'service_name' - include_tasks: consul/windows.yml when: ansible_system == 'Win32NT' - -# On Windows json attribute is missing when it's []. -- name: Extract Geth websocket IP and port - set_fact: - geth_api_addresses: | - {{ (geth_rpc_services.results - + geth_ws_services.results) - | selectattr("json", "defined") - | sum(attribute="json", start=[]) - | map(attribute='ServiceMeta.url') - | list }} + loop: '{{ geth_node_api_consul_names }}' + loop_control: + loop_var: 'service_name' - name: Extract Goerli Geth WebSocket URL set_fact: