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,7 +66,12 @@
# requiring a mount restart the systemctl # requiring a mount restart the systemctl
# command is used with the "reload-or-restart" # command is used with the "reload-or-restart"
# argument. Additionally this command escapes # argument. Additionally this command escapes
# the name of the mount. # 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 - name: Set the state of the mount
shell: >- shell: >-
systemctl systemctl
@ -78,6 +83,11 @@
- item.state is defined - item.state is defined
tags: tags:
- skip_ansible_lint - 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) - name: Unload mount(s)
systemd: systemd: