infra-nimbus/ansible/roles/get-geth-api-urls/tasks/consul/posix.yml

29 lines
861 B
YAML
Raw Normal View History

---
- name: Find available data centers
uri:
url: '{{ consul_catalog_url }}/datacenters'
register: data_centers
- name: Find available Geth API RPC services
uri:
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/{{ 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 }}