From 841a0f33147715a7431de28b7666c68008c56b5a Mon Sep 17 00:00:00 2001 From: Yves MOYROUD <41052194+YvesMP@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:46:26 +0200 Subject: [PATCH] modules/mount.py --- plugins/modules/mount.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/modules/mount.py b/plugins/modules/mount.py index 78ccf39..7b357e6 100644 --- a/plugins/modules/mount.py +++ b/plugins/modules/mount.py @@ -186,6 +186,23 @@ EXAMPLES = r''' path: /tmp/mnt-pnt state: remounted +# The following will fail on first run +# if /home/mydir is not empty after unmounting, +# though unmount and remove from fstab are successfull. +# It will be successfull on subsequent runs (already unmounted). +- name: Unmount and remove from fstab, then if unmount was necessary try to remove mountpoint /home/mydir + ansible.posix.mount: + path: /home/mydir + state: absent +# The following will not fail on first run +# if /home/mydir is not empty after unmounting. +# It will leave /home/mydir and its content (if any) after unmounting. +- name: Unmount and remove from fstab, but keep /home/mydir + ansible.posix.mount: + path: /home/mydir + state: absent + keep_mountpoint: true + # The following will not save changes to fstab, and only be temporary until # a reboot, or until calling "state: unmounted" followed by "state: mounted" # on the same "path"