--- - name: Delay test hosts: mount become: false gather_facts: false vars: nfs_srv: 10.10.42.180 nfs_mnt: /backups nfs_path: /var/tmp/nfs_mnt tasks: - name: Mount NFS share ansible.posix.mount: path: "{{ nfs_path }}" src: "{{ nfs_srv }}:{{ nfs_mnt }}" fstype: nfs state: ephemeral - name: Pause ansible.builtin.pause: minutes: 1 - name: Try to unmount the filesystem block: - name: Unmount filesystem ansible.posix.mount: path: "{{ nfs_path }}" state: unmounted delay: 3 retries: 3 # - name: Fail # ansible.builtin.fail: # msg: Failed as requested from task rescue: # - name: Kill processes using the filesystem # ansible.builtin.command: # cmd: "fuser -k {{ nfs_path }}" # failed_when: false - name: "Rescue: Lazy unmount the NFS share" ansible.builtin.command: cmd: "umount -l {{ nfs_path }}" - name: Log unmount rescue to syslogger community.general.syslogger: msg: "Unable to unmount the NFS share '{{ nfs_path }}' using normal method. Unmounted via lazy unmount." ident: ansbl_rear_unmount_rescue vars: actors: "rear_unmount_rescue" title: > ReaR Unmount Rescue summary: "Unable to unmount the filesystem {{ nfs_path }} using normal method. Rescued via lazy unmount." severity: "high" flags: ["inhibitor"]