mirror of
https://gitea.0xace.cc/ansible-galaxy/consul.git
synced 2024-11-25 06:37:18 +00:00
45 lines
1.0 KiB
YAML
45 lines
1.0 KiB
YAML
- block:
|
|
- name: Set var for cluster nodes list
|
|
set_fact:
|
|
cluster_node_list: []
|
|
|
|
- name: Get cluster nodes
|
|
environment:
|
|
no_proxy: 127.0.0.1
|
|
ansible.builtin.uri:
|
|
url: http://127.0.0.1:8500/v1/status/peers
|
|
method: GET
|
|
status_code: 200
|
|
body_format: json
|
|
return_content: true
|
|
register: cluster_nodes
|
|
failed_when: false
|
|
|
|
- name: Print cluster nodes
|
|
debug:
|
|
msg: "{{ cluster_nodes.json }}"
|
|
verbosity: 2
|
|
when: cluster_nodes.json is defined
|
|
|
|
- name: Print cluster nodes
|
|
debug:
|
|
msg: "{{ item }}"
|
|
verbosity: 2
|
|
loop: "{{ cluster_nodes.json }}"
|
|
when: cluster_nodes.json is defined
|
|
|
|
- name: Merge cluster nodes list
|
|
set_fact:
|
|
cluster_node_list: "{{ cluster_node_list + [item|split(':')|first] }}"
|
|
loop: "{{ cluster_nodes.json }}"
|
|
when: cluster_nodes.json is defined
|
|
|
|
- name: Print cluster nodes list
|
|
debug:
|
|
msg: "{{ cluster_node_list }}"
|
|
verbosity: 2
|
|
when: cluster_nodes.json is defined
|
|
|
|
run_once: true
|
|
ignore_errors: true
|