Skip to content

Commit 5c52e03

Browse files
committed
Add support to check versions
1 parent 1a8d3b8 commit 5c52e03

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tasks/cluster/checks.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
---
22

3-
- name: cluster | check cluster group
3+
- name: check | cluster group should be valid
44
fail:
55
msg="Your configuration is not valid 'rabbitmq_cluster_group' varaible with value '{{ rabbitmq_cluster_group }}' is not valid group."
66
when: "{{ groups[rabbitmq_cluster_group] is not defined }}"
7+
8+
- name: check | get rabbitmq version in each node in the cluster
9+
shell: rabbitmqctl status|grep "{rabbit,\"RabbitMQ\"" | cut -d, -f3 | cut -d "\"" -f2
10+
delegate_to: "{{ item }}"
11+
changed_when: false
12+
run_once: true
13+
with_items: "{{ groups[rabbitmq_cluster_group] }}"
14+
register: cluster_versions_command
15+
16+
- name: check | Create a list of nodes and versions
17+
set_fact:
18+
rabbit_cluster_nodes_version: "{{ [{ 'node': item.item, 'version': item.stdout }] + rabbit_cluster_nodes_version }}"
19+
with_items: "{{ cluster_versions_command.results }}"
20+
run_once: true
21+
22+
# Filter out node values that are not the same version then compae with original node version
23+
# if lists dont match then we have different versions in our cluster
24+
- name: check | Fail if version in cluster dont match
25+
fail:
26+
msg="Rabbiqmq version in cluster dont match. Node versions = {{rabbit_cluster_nodes_version }}"
27+
run_once: true
28+
when: "{{ rabbit_cluster_nodes_version | selectattr('version', 'equalto', rabbit_cluster_nodes_version[0]['version']) | list != rabbit_cluster_nodes_version }}"

0 commit comments

Comments
 (0)