Improve Galera running, stop, bootstrap behavior

Adds a check to see if Galera is running.
Improves check of cluster size to only test when Galera is running.
Improves Stop operation to consume new check.
Improves Bootstrap operation to consume new check.

Co-Authored-By: Kevin Carter <kevin.carter@rackspace.com>
Change-Id: I44f5ff5a7240f3583628fca4d039234f9e34ddf7
Closes-Bug: 1438368
This commit is contained in:
Steve Lewis 2015-03-30 12:06:12 -07:00
parent 261310d58d
commit 2d4f9c750f
2 changed files with 22 additions and 3 deletions

View File

@ -13,6 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Check if mysql is running
shell: "pgrep -fl mysqld"
register: mysql_running
changed_when: mysql_running.rc != 0
tags:
- galera-bootstrap
- name: Get incoming addresses from cluster
shell: |
mysql -e 'show status like "wsrep_incoming_addresses"\G'|awk '/Value/{print $2}'
@ -26,7 +33,9 @@
service:
name: mysql
state: restarted
when: "not wsrep_incoming_addresses.stdout|search('{{ ansible_ssh_host }}')"
when: >
"not wsrep_incoming_addresses.stdout|search('{{ ansible_ssh_host }}')" or
mysql_running != 0
tags:
- galera-add-node
- galera-bootstrap

View File

@ -13,11 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Check if mysql is running
shell: "pgrep -fl mysqld"
register: mysql_running
changed_when: mysql_running.rc != 0
tags:
- galera-bootstrap
- name: Check wsrep cluster size
shell: |
mysql -e 'show status like "wsrep_cluster_size%"\G'|awk '/Value/{print $2}'
register: wsrep_cluster_size
changed_when: wsrep_cluster_size.stdout|search("1")
when: mysql_running.rc == 0
tags:
- galera-bootstrap
@ -27,7 +35,9 @@
state: stopped
pattern: mysqld
register: mysqlstopped
when: wsrep_cluster_size.stdout | search("1") or wsrep_cluster_size.stderr | search("ERROR")
when: >
mysql_running.rc == 0 and
(wsrep_cluster_size.stdout | search("1") or wsrep_cluster_size.stderr | search("ERROR"))
tags:
- galera-bootstrap
@ -43,6 +53,6 @@
name: mysql
state: restarted
args: --wsrep-new-cluster
when: wsrep_cluster_size.stdout|search("1") or mysqlstopped|changed or not mysql_running.stdout|search("mysql")
when: wsrep_cluster_size.stdout|search("1") or mysqlstopped|changed or mysql_running != 0
tags:
- galera-bootstrap