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:
parent
af8e44dcb2
commit
bf3480a7ff
|
@ -24,6 +24,10 @@ galera_upgrade: false
|
||||||
galera_wsrep_node_name: "{{ inventory_hostname }}"
|
galera_wsrep_node_name: "{{ inventory_hostname }}"
|
||||||
galera_cluster_name: openstack_galera_cluster
|
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
|
# The galera server-id should be set on all cluster nodes to ensure
|
||||||
# that replication is handled correctly and the error
|
# that replication is handled correctly and the error
|
||||||
# "Warning: You should set server-id to a non-0 value if master_host is
|
# "Warning: You should set server-id to a non-0 value if master_host is
|
||||||
|
|
|
@ -24,9 +24,9 @@ DOCUMENTATION = """
|
||||||
---
|
---
|
||||||
module: mysql_status_facts
|
module: mysql_status_facts
|
||||||
short_description:
|
short_description:
|
||||||
- A module for gathering mysql status facts.
|
- A module for gathering mysql status and global variable facts.
|
||||||
description:
|
description:
|
||||||
- A module for gathering mysql status facts.
|
- A module for gathering mysql status and global variable facts.
|
||||||
author: Rcbops
|
author: Rcbops
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -44,13 +44,17 @@ class MysqlStatusFacts(object):
|
||||||
def gather_facts(self):
|
def gather_facts(self):
|
||||||
"""Get information about mysql status."""
|
"""Get information about mysql status."""
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(["mysql", "-e", "show status"],
|
status = subprocess.check_output(["mysql", "-e", "show status"],
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
|
global_vars = subprocess.check_output(["mysql", "-e",
|
||||||
|
"show global variables"],
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
message = 'Mysql fact collection failed: "%s".' % e.output.strip()
|
message = 'Mysql fact collection failed: "%s".' % e.output.strip()
|
||||||
self.module.fail_json(msg=message)
|
self.module.fail_json(msg=message)
|
||||||
else:
|
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)
|
facts = dict(l.split('\t') for l in lines if l)
|
||||||
self.module.exit_json(
|
self.module.exit_json(
|
||||||
changed=self.state_change,
|
changed=self.state_change,
|
||||||
|
|
|
@ -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.
|
|
@ -64,6 +64,22 @@
|
||||||
tags:
|
tags:
|
||||||
- galera-cluster-state-check
|
- 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:
|
- set_fact:
|
||||||
galera_existing_cluster: true
|
galera_existing_cluster: true
|
||||||
when: mysql_running.rc == 0
|
when: mysql_running.rc == 0
|
||||||
|
|
Loading…
Reference in New Issue