openstack-ansible-galera_se.../tasks/galera_cluster_state.yml
Andy McCrae 8a9127efbc Prevent galera_cluster_name from changing.
On a running galera cluster, we don't want to unintentionally allow a
galera_cluster_name from changing. This will cause a cluster to fail to
start (if the nodes are restarted sequentially) as the cluter name value
has changed.

To ensure we can still change this value, a new
"galera_force_change_cluster_name" variable is added, which can be set
to "True" in order to change the cluster name.

Change-Id: I8bae038bd207a15d5731b9c91b78df851a4c1986
2016-09-13 17:32:53 +01:00

88 lines
3.1 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.
- include: galera_running_check.yml
vars:
num_retries: 1
wait_delay: 3
- name: Check for cluster state failure
fail:
msg: |
The cluster may be broken, mysql is not running but appears to be
installed. Fix it before re-running the playbook or override with
'openstack-ansible -e galera_ignore_cluster_state=true galera-install.yml'.
when:
- not galera_ignore_cluster_state | bool
- mysql_running.rc == 1
- mysql_running.stderr | search("Check that mysqld is running and that the socket")
tags:
- galera-cluster-state-check
- name: Gather mysql facts
mysql_status_facts:
ignore_errors: true
tags:
- galera-cluster-state-check
- name: Check for cluster state failure
fail:
msg: |
The cluster may be broken, mysql is running but unable to gather mysql facts.
Fix it before re-running the playbook or override with
'openstack-ansible -e galera_ignore_cluster_state=true galera-install.yml'.
when:
- not galera_ignore_cluster_state | bool
- mysql_running.rc == 0
- mysql_status is not defined
tags:
- galera-cluster-state-check
- name: Check for cluster state failure
fail:
msg: |
wsrep_incoming_addresses does not match across the cluster. Please fix before
re-running the playbooks or override with
'openstack-ansible -e galera_ignore_cluster_state=true galera-install.yml'.
with_items: "{{ play_hosts }}"
when:
- not galera_ignore_cluster_state | bool
- mysql_running.rc == 0
- mysql_status['wsrep_incoming_addresses'] != hostvars[item]['mysql_status']['wsrep_incoming_addresses']
tags:
- galera-cluster-state-check
- name: Fail if galera_cluster_name doesnt match file 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.
If you are sure you want to change this variable you can force change your
galera_cluster_name variable by setting 'galera_force_change_cluster_name: True'"
when:
- mysql_running.rc == 0
- mysql_status['wsrep_cluster_name'] != galera_cluster_name
- not galera_force_change_cluster_name | bool
tags:
- galera-cluster-state-check
- set_fact:
galera_existing_cluster: true
when: mysql_running.rc == 0
tags:
- galera-cluster-state-check