--- - 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 }}