Use a private namespaced var for cluster name check

The galera cluster check uses "cluster_name" as a task return variable
when pulling the cluster name from an existing cluster. As one
might imagine, the cluster_name variable is very ambiguous and could
exist in a user's user_variables or inventory somewhere, which breaks
this check and fails the role execution. Instead of using 'cluster_name'
we can just return the task result to a private namespaced var
'_cluster_name' and use that for the assertion instead.

'node_status' is a similar check, also changed to '_node_status'

Change-Id: I0e530e67238a42e63f25ce0d59eefca2b7a2099a
This commit is contained in:
Logan V 2019-05-30 16:26:00 -05:00
parent 2460120427
commit 1359811084

View File

@ -18,7 +18,7 @@
mysql --silent --skip-column-names --connect-timeout=10 -e 'SHOW STATUS LIKE "wsrep_local_state";'
failed_when: false
changed_when: false
register: node_status
register: _node_status
- name: Fail if cluster is out of sync
fail:
@ -27,15 +27,15 @@
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"]
- _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
register: _cluster_name
- name: Fail if galera_cluster_name doesnt match provided value
fail:
@ -47,5 +47,5 @@
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
- _cluster_name.rc != 0
- (_cluster_name.stdout.split()[-1] | default(false)) != galera_cluster_name