/
galera_cluster_state.yml
51 lines (47 loc) · 1.96 KB
/
galera_cluster_state.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
# Copyright 2015, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Check node status
command: >
mysql --silent --skip-column-names --connect-timeout=10 -e 'SHOW STATUS LIKE "wsrep_local_state";'
failed_when: false
changed_when: false
register: node_status
- name: Fail if cluster is out of sync
fail:
msg: >
The cluster may be broken, the cluster state is not known to be good.
Fix the cluster state before re-running the playbooks. To ignore the
cluster state set '-e galera_ignore_cluster_state=true'.
when:
- node_status.rc != 0
- (node_status.stdout.split()[-1] | default(false)) in ["2", "4"]
- name: Check cluster name
command: >
mysql --silent --skip-column-names --connect-timeout=10 -e 'SHOW VARIABLES LIKE "wsrep_cluster_name";'
failed_when: false
changed_when: false
register: cluster_name
- name: Fail if galera_cluster_name doesnt match provided value
fail:
msg: >
The galera_cluster_name variable does not match what is set in mysql.
Check your galera_cluster_name setting in your user_*.yml files in
"/etc/openstack_deploy" and compare to the current value in
"/etc/mysql/conf.d/cluster.cnf" on the host, and the "wsrep_cluster_name"
value set in your running galera cluster. To ignore the
cluster state set '-e galera_ignore_cluster_state=true'.
when:
- cluster_name.rc != 0
- (cluster_name.stdout.split()[-1] | default(false)) != galera_cluster_name