From 2d4f9c750f0bf8118181df66b7a800cbc860f7ca Mon Sep 17 00:00:00 2001 From: Steve Lewis Date: Mon, 30 Mar 2015 12:06:12 -0700 Subject: [PATCH] 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 Change-Id: I44f5ff5a7240f3583628fca4d039234f9e34ddf7 Closes-Bug: 1438368 --- .../roles/galera_server/tasks/galera_add_node.yml | 11 ++++++++++- .../roles/galera_server/tasks/galera_bootstrap.yml | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/playbooks/roles/galera_server/tasks/galera_add_node.yml b/playbooks/roles/galera_server/tasks/galera_add_node.yml index 3f798d6b88..d9c977aea9 100644 --- a/playbooks/roles/galera_server/tasks/galera_add_node.yml +++ b/playbooks/roles/galera_server/tasks/galera_add_node.yml @@ -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 diff --git a/playbooks/roles/galera_server/tasks/galera_bootstrap.yml b/playbooks/roles/galera_server/tasks/galera_bootstrap.yml index 5ec5f446c7..7460c31fe6 100644 --- a/playbooks/roles/galera_server/tasks/galera_bootstrap.yml +++ b/playbooks/roles/galera_server/tasks/galera_bootstrap.yml @@ -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