--- - name: Get data centers uri: url: '{{ consul_catalog_url }}/datacenters' register: data_centers - name: Get AlertManager node addresses uri: url: '{{ consul_catalog_url }}/service/{{ alertmanager_service_name }}?dc={{ item }}' method: GET validate_certs: no with_items: '{{ data_centers.json }}' register: alertmanager_services - name: Extract IP addresses set_fact: alertmanager_cluster_peers: | {{ alertmanager_services.results | sum(attribute="json", start=[]) | sort(attribute='Node') | list }}