mirror of
https://gitea.0xace.cc/ansible-galaxy/consul.git
synced 2025-04-05 21:51:57 +00:00
rewrite initial cluster nodes discovering
This commit is contained in:
parent
4c80707b1c
commit
61e14c682d
@ -4,33 +4,39 @@
|
|||||||
cluster_node_list: []
|
cluster_node_list: []
|
||||||
|
|
||||||
- name: Get cluster nodes
|
- name: Get cluster nodes
|
||||||
command: curl http://127.0.0.1:8500/v1/status/peers
|
ansible.builtin.uri:
|
||||||
environment:
|
url: http://127.0.0.1:8500/v1/status/peers
|
||||||
no_proxy: 127.0.0.1
|
method: GET
|
||||||
|
status_code: 200
|
||||||
|
body_format: json
|
||||||
|
return_content: true
|
||||||
register: cluster_nodes
|
register: cluster_nodes
|
||||||
changed_when: false
|
failed_when: false
|
||||||
no_log: true
|
|
||||||
|
|
||||||
- name: Print cluster nodes
|
- name: Print cluster nodes
|
||||||
debug:
|
debug:
|
||||||
msg: "{{ cluster_nodes.stdout }}"
|
msg: "{{ cluster_nodes.json }}"
|
||||||
verbosity: 2
|
verbosity: 2
|
||||||
|
when: cluster_nodes.json is defined
|
||||||
|
|
||||||
- name: Print cluster nodes
|
- name: Print cluster nodes
|
||||||
debug:
|
debug:
|
||||||
msg: "{{ item }}"
|
msg: "{{ item }}"
|
||||||
verbosity: 2
|
verbosity: 2
|
||||||
loop: "{{ cluster_nodes.stdout | from_json }}"
|
loop: "{{ cluster_nodes.json }}"
|
||||||
|
when: cluster_nodes.json is defined
|
||||||
|
|
||||||
- name: Merge cluster nodes list
|
- name: Merge cluster nodes list
|
||||||
set_fact:
|
set_fact:
|
||||||
cluster_node_list: "{{ cluster_node_list + [item|split(':')|first] }}"
|
cluster_node_list: "{{ cluster_node_list + [item|split(':')|first] }}"
|
||||||
loop: "{{ cluster_nodes.stdout | from_json }}"
|
loop: "{{ cluster_nodes.json }}"
|
||||||
|
when: cluster_nodes.json is defined
|
||||||
|
|
||||||
- name: Print cluster nodes list
|
- name: Print cluster nodes list
|
||||||
debug:
|
debug:
|
||||||
msg: "{{ cluster_node_list }}"
|
msg: "{{ cluster_node_list }}"
|
||||||
verbosity: 2
|
verbosity: 2
|
||||||
|
when: cluster_nodes.json is defined
|
||||||
|
|
||||||
run_once: true
|
run_once: true
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user