Browse Source

Merge "When upgrading, only stop the service if it exists"

Zuul 4 months ago
parent
commit
1c3c704dd8
1 changed files with 16 additions and 1 deletions
  1. 16
    1
      tasks/galera_upgrade_pre.yml

+ 16
- 1
tasks/galera_upgrade_pre.yml View File

@@ -13,15 +13,30 @@
13 13
 # See the License for the specific language governing permissions and
14 14
 # limitations under the License.
15 15
 
16
+# When doing a rolling replacement of an existing cluster,
17
+# a service may not yet exist on the target host. This will
18
+# cause the service stop task to fail. To cater for this
19
+# we only try to stop the service is it exists.
20
+- name: Check whether a mysql service exists yet
21
+  shell: >-
22
+    systemctl list-unit-files --state=enabled --type=service | grep "^mysql.service .* enabled$"
23
+  args:
24
+    executable: /bin/bash
25
+    warn: no
26
+  changed_when: false
27
+  failed_when: false
28
+  register: _mysql_service_exists
29
+
16 30
 - name: Stop MariaDB
17 31
   systemd:
18 32
     name: mysql
19 33
     state: stopped
20
-  failed_when: "{{ (not galera_ignore_cluster_state | bool) | default(omit, false) }}"
21 34
   register: galera_restart_fall_back
22 35
   until: galera_restart_fall_back is success
23 36
   retries: 3
24 37
   delay: 5
38
+  when:
39
+    - _mysql_service_exists.rc == 0
25 40
 
26 41
 - name: UN-Install galera-server package
27 42
   package:

Loading…
Cancel
Save