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
(cherry picked from commit 8a9127efbc)
This commit is contained in:
Andy McCrae 2016-09-13 16:15:03 +01:00 committed by Andy McCrae
parent af8e44dcb2
commit bf3480a7ff
4 changed files with 43 additions and 4 deletions

View File

@ -24,6 +24,10 @@ galera_upgrade: false
galera_wsrep_node_name: "{{ inventory_hostname }}"
galera_cluster_name: openstack_galera_cluster
# This variable will prevent the galera_cluster_name from changing unintentionally on a running cluster.
# To intentionally change the galera_cluster_name set this variable to True
galera_force_change_cluster_name: False
# The galera server-id should be set on all cluster nodes to ensure
# that replication is handled correctly and the error
# "Warning: You should set server-id to a non-0 value if master_host is

View File

@ -24,9 +24,9 @@ DOCUMENTATION = """
---
module: mysql_status_facts
short_description:
- A module for gathering mysql status facts.
- A module for gathering mysql status and global variable facts.
description:
- A module for gathering mysql status facts.
- A module for gathering mysql status and global variable facts.
author: Rcbops
"""
@ -44,13 +44,17 @@ class MysqlStatusFacts(object):
def gather_facts(self):
"""Get information about mysql status."""
try:
output = subprocess.check_output(["mysql", "-e", "show status"],
status = subprocess.check_output(["mysql", "-e", "show status"],
stderr=subprocess.STDOUT)
global_vars = subprocess.check_output(["mysql", "-e",
"show global variables"],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
message = 'Mysql fact collection failed: "%s".' % e.output.strip()
self.module.fail_json(msg=message)
else:
lines = output.split('\n')
lines = status.split('\n')
lines += global_vars.split('\n')
facts = dict(l.split('\t') for l in lines if l)
self.module.exit_json(
changed=self.state_change,

View File

@ -0,0 +1,15 @@
---
features:
- The ``openstack-ansible-galera_server`` role will now prevent
deployers from changing the ``galera_cluster_name`` variable
on clusters that already have a value set in a running galera
cluster.
You can set the new ``galera_force_change_cluster_name``
variable to ``True`` to force the ``galera_cluster_name``
variable to be changed.
We recommend setting this by running the galera-install.yml playbook
with ``-e galera_force_change_cluster_name=True``, to avoid
changing the ``galera_cluster_name`` variable unintentionally.
Use with caution, changing the ``galera_cluster_name`` value
can cause your cluster to fail, as the nodes won't join if restarted
sequentially.

View File

@ -64,6 +64,22 @@
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