Add mount state rescue block

The mount state could be volitile making it so the "restart-or-reload"
option fails to execute. If this happens the task will now be rescued
and the mount state will be attempted using the regular systemd
module.

Change-Id: I86fc03ad7c72fa4cfdfc598f552f936dda653926
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-10-22 14:10:00 -05:00 committed by Kevin Carter (cloudnull)
parent e62715f740
commit 29412148c3

View File

@ -66,18 +66,28 @@
# requiring a mount restart the systemctl
# command is used with the "reload-or-restart"
# argument. Additionally this command escapes
# the name of the mount.
- name: Set the state of the mount
shell: >-
systemctl
{{ systemd_mount_states[item.state] }}
$(systemd-escape -p --suffix="{{ systemd_mount_suffix }}" "{{ systemd_mount_item }}")
args:
warn: no
when:
- item.state is defined
tags:
- skip_ansible_lint
# the name of the mount. If this command fails
# the task will be rescued and the regular
# systemd module will be attempted before
# failing the task run.
- name: Mount state block
block:
- name: Set the state of the mount
shell: >-
systemctl
{{ systemd_mount_states[item.state] }}
$(systemd-escape -p --suffix="{{ systemd_mount_suffix }}" "{{ systemd_mount_item }}")
args:
warn: no
when:
- item.state is defined
tags:
- skip_ansible_lint
rescue:
- name: Set the state of the mount (fallback)
systemd:
name: "{{ mount_service_name.stdout }}"
state: "{{ item.state }}"
- name: Unload mount(s)
systemd: