openstack-ansible-galera_se.../tasks/galera_server_cluster_state...

52 lines
2.0 KiB
YAML

---
# 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