When upgrading, only stop the service if it exists
In Id9c4f11b3536e7f9d510f5ef8e6d82a82a96adac we implemented a failed_when condition to ignore the state of the service stop task when `galera_ignore_cluster_state=true` is passed through. Unfortunately, the omit filter does not work in a task context [1], resulting in the task always failing because the omit placeholder string is evaluated as true. This makes the task always fail when running an upgrade. In this patch we change the task flow to evaluate whether a service exists, and if it does then to stop it - otherwise skip that task. This should cater for the rolling replacement use-case and will work in every other situation too. [1] https://github.com/ansible/ansible/issues/25678 Change-Id: Ib26c807057b9114e02ad32c759a5028555788363
This commit is contained in:
parent
a6c67fa482
commit
69e2c736a0
@ -13,15 +13,30 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# When doing a rolling replacement of an existing cluster,
|
||||
# a service may not yet exist on the target host. This will
|
||||
# cause the service stop task to fail. To cater for this
|
||||
# we only try to stop the service is it exists.
|
||||
- name: Check whether a mysql service exists yet
|
||||
shell: >-
|
||||
systemctl list-unit-files --state=enabled --type=service | grep "^mysql.service .* enabled$"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
warn: no
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: _mysql_service_exists
|
||||
|
||||
- name: Stop MariaDB
|
||||
systemd:
|
||||
name: mysql
|
||||
state: stopped
|
||||
failed_when: "{{ (not galera_ignore_cluster_state | bool) | default(omit, false) }}"
|
||||
register: galera_restart_fall_back
|
||||
until: galera_restart_fall_back is success
|
||||
retries: 3
|
||||
delay: 5
|
||||
when:
|
||||
- _mysql_service_exists.rc == 0
|
||||
|
||||
- name: UN-Install galera-server package
|
||||
package:
|
||||
|
Loading…
x
Reference in New Issue
Block a user