consul/tasks/pre_check.yaml

37 lines
846 B
YAML

- 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 }}"
verbosity: 2
- name: Print cluster nodes
debug:
msg: "{{ item }}"
verbosity: 2
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 }}"
verbosity: 2
run_once: true
ignore_errors: yes