2022-07-28 14:14:26 +00:00
|
|
|
- block:
|
|
|
|
- name: Set var for cluster nodes list
|
|
|
|
set_fact:
|
|
|
|
cluster_node_list: []
|
|
|
|
|
|
|
|
- name: Get cluster nodes
|
2023-02-07 10:40:11 +00:00
|
|
|
ansible.builtin.uri:
|
|
|
|
url: http://127.0.0.1:8500/v1/status/peers
|
|
|
|
method: GET
|
|
|
|
status_code: 200
|
|
|
|
body_format: json
|
|
|
|
return_content: true
|
2022-07-28 14:14:26 +00:00
|
|
|
register: cluster_nodes
|
2023-02-07 10:40:11 +00:00
|
|
|
failed_when: false
|
2022-07-28 14:14:26 +00:00
|
|
|
|
|
|
|
- name: Print cluster nodes
|
|
|
|
debug:
|
2023-02-07 10:40:11 +00:00
|
|
|
msg: "{{ cluster_nodes.json }}"
|
2023-01-12 15:52:45 +00:00
|
|
|
verbosity: 2
|
2023-02-07 10:40:11 +00:00
|
|
|
when: cluster_nodes.json is defined
|
2022-07-28 14:14:26 +00:00
|
|
|
|
|
|
|
- name: Print cluster nodes
|
|
|
|
debug:
|
|
|
|
msg: "{{ item }}"
|
2023-01-12 15:52:45 +00:00
|
|
|
verbosity: 2
|
2023-02-07 10:40:11 +00:00
|
|
|
loop: "{{ cluster_nodes.json }}"
|
|
|
|
when: cluster_nodes.json is defined
|
2022-07-28 14:14:26 +00:00
|
|
|
|
|
|
|
- name: Merge cluster nodes list
|
|
|
|
set_fact:
|
|
|
|
cluster_node_list: "{{ cluster_node_list + [item|split(':')|first] }}"
|
2023-02-07 10:40:11 +00:00
|
|
|
loop: "{{ cluster_nodes.json }}"
|
|
|
|
when: cluster_nodes.json is defined
|
2022-07-28 14:14:26 +00:00
|
|
|
|
|
|
|
- name: Print cluster nodes list
|
|
|
|
debug:
|
|
|
|
msg: "{{ cluster_node_list }}"
|
2023-01-12 15:52:45 +00:00
|
|
|
verbosity: 2
|
2023-02-07 10:40:11 +00:00
|
|
|
when: cluster_nodes.json is defined
|
2022-07-28 14:14:26 +00:00
|
|
|
|
|
|
|
run_once: true
|
2023-02-07 10:40:11 +00:00
|
|
|
ignore_errors: true
|