get-geth-api-urls: query for OpenEthereum nodes too

https://github.com/status-im/infra-nimbus/issues/80

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2022-06-03 12:01:44 +02:00
parent f82df25498
commit c8fa895f98
No known key found for this signature in database
GPG Key ID: 09AA5403E54D9931
5 changed files with 39 additions and 18 deletions

View File

@ -111,7 +111,7 @@
- name: infra-role-geth - name: infra-role-geth
src: git@github.com:status-im/infra-role-geth.git src: git@github.com:status-im/infra-role-geth.git
version: 3de59d6ae76b69291905d16c264a1d11a5e2e955 version: 11cdfe59ff57faaa33ed0b6d98414ece8862b20d
scm: git scm: git
- name: infra-role-geth-exporter - name: infra-role-geth-exporter
@ -121,5 +121,5 @@
- name: infra-role-openethereum - name: infra-role-openethereum
src: git@github.com:status-im/infra-role-openethereum.git src: git@github.com:status-im/infra-role-openethereum.git
version: 83996de847c3573c1957d563782921cb24c79971 version: 4e8fb26533ae97924dec258e158119aa4d3edf0f
scm: git scm: git

View File

@ -6,7 +6,10 @@ eth2_to_eth1_map:
eth2_network_name: '{{ beacon_node_network | mandatory }}' eth2_network_name: '{{ beacon_node_network | mandatory }}'
eth1_network_name: '{{ eth2_to_eth1_map[eth2_network_name] | 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. # The more the merrier, since we don't want to hit Infura throttling.
infura_api_tokens: infura_api_tokens:
- '9e2f2cc13f70432f8b87dbe7d51b81db' - '9e2f2cc13f70432f8b87dbe7d51b81db'

View File

@ -6,12 +6,23 @@
- name: Find available Geth API RPC services - name: Find available Geth API RPC services
uri: 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 }}' with_items: '{{ data_centers.json }}'
register: geth_rpc_services register: geth_rpc_services
- name: Find available Geth API WebSocket services - name: Find available Geth API WebSocket services
uri: 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 }}' with_items: '{{ data_centers.json }}'
register: geth_ws_services 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 }}

View File

@ -8,7 +8,7 @@
- name: Find available Geth API RPC services - name: Find available Geth API RPC services
win_uri: 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' content_type: 'application/json'
return_content: true return_content: true
with_items: '{{ data_centers.json }}' with_items: '{{ data_centers.json }}'
@ -16,8 +16,20 @@
- name: Find available Geth WebSocket services - name: Find available Geth WebSocket services
win_uri: 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' content_type: 'application/json'
return_content: true return_content: true
with_items: '{{ data_centers.json }}' with_items: '{{ data_centers.json }}'
register: geth_ws_services 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 }}

View File

@ -1,20 +1,15 @@
--- ---
- include_tasks: consul/posix.yml - include_tasks: consul/posix.yml
when: ansible_system in ['Linux', 'Darwin'] when: ansible_system in ['Linux', 'Darwin']
loop: '{{ geth_node_api_consul_names }}'
loop_control:
loop_var: 'service_name'
- include_tasks: consul/windows.yml - include_tasks: consul/windows.yml
when: ansible_system == 'Win32NT' when: ansible_system == 'Win32NT'
loop: '{{ geth_node_api_consul_names }}'
# On Windows json attribute is missing when it's []. loop_control:
- name: Extract Geth websocket IP and port loop_var: 'service_name'
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 }}
- name: Extract Goerli Geth WebSocket URL - name: Extract Goerli Geth WebSocket URL
set_fact: set_fact: