Files
openstack-ansible/playbooks/roles/galera_server/tasks/galera_add_node.yml
git-harry c5c577518d Fix conditional galera restarts
The task files galera_add_node.yml and galera_bootstrap.yml in the
galera_server role both restart mysql based on conditions. These
conditions are incorrectly defined causing restarts to happen every time
.

This commit addresses several issues related to how these conditions are
defined and compared.

- The the pgrep pattern for the task 'Check if mysql is running' has
been modified so that is no longer matches the ansible shell command. It
also ignores errors generated by pgrep failing to find a match so that
it can be used by other tasks.

- The registered variables, used by the when clauses, have appropriately
defined changed attributes. This commit modifies the when clauses to
make use of them.

- The when clause for the tasks 'bootstrap cluster (initialise mysql
with --wsrep-new-cluster)' and 'Restart mysql' were always being met
because 'mysql_running != 0' should be 'mysql_running.rc != 0', they has
been adjusted to use the changed status.

Closes-bug: #1444308
Change-Id: Ib2879bfe9754575fd984a1f1d132d5a42b848e21
2015-04-15 15:31:59 +01:00

41 lines
1.2 KiB
YAML

---
# Copyright 2014, 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 if mysql is running
shell: "pgrep -fl [m]ysqld"
register: mysql_running
changed_when: mysql_running.rc != 0
ignore_errors: True
tags:
- galera-bootstrap
- name: Get incoming addresses from cluster
shell: |
mysql -e 'show status like "wsrep_incoming_addresses"\G'|awk '/Value/{print $2}'
register: wsrep_incoming_addresses
changed_when: "not wsrep_incoming_addresses.stdout|search('{{ ansible_ssh_host }}')"
tags:
- galera-add-node
- galera-bootstrap
- name: Restart mysql
service:
name: mysql
state: restarted
when: wsrep_incoming_addresses|changed or mysql_running|changed
tags:
- galera-add-node
- galera-bootstrap