infra-nimbus/ansible/roles/get-geth-web3-urls/tasks/main.yml

26 lines
788 B
YAML

---
- name: Find available data centers
uri:
url: '{{ consul_catalog_url }}/datacenters'
register: data_centers
- name: Find available geth websocket services
uri:
url: '{{ consul_catalog_url }}/service/{{ web3_geth_node_consul_name }}?dc={{ item }}'
with_items: '{{ data_centers.json }}'
register: geth_ws_services
- name: Extract Geth websocket IP and port
set_fact:
geth_ws_addresses: |
{{ geth_ws_services.results
| sum(attribute="json", start=[])
| json_query("[].[ServiceAddress, ServicePort]")
| map('join', ':')
| list }}
- name: Extract Goerli Geth WebSocket URL
set_fact:
# our nodes first (will be used by default) then an infura node
beacon_node_web3_urls: "{{ geth_ws_addresses + [ selected_infura_url ] }}"