- block: - name: Set var for cluster nodes list set_fact: cluster_node_list: [] - name: Get cluster nodes command: curl http://127.0.0.1:8500/v1/status/peers environment: no_proxy: 127.0.0.1 register: cluster_nodes changed_when: false no_log: true - name: Print cluster nodes debug: msg: "{{ cluster_nodes.stdout }}" - name: Print cluster nodes debug: msg: "{{ item }}" loop: "{{ cluster_nodes.stdout | from_json }}" - name: Merge cluster nodes list set_fact: cluster_node_list: "{{ cluster_node_list + [item|split(':')|first] }}" loop: "{{ cluster_nodes.stdout | from_json }}" - name: Print cluster nodes list debug: msg: "{{ cluster_node_list }}" run_once: true ignore_errors: yes