Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mount.py no rmdir when state=='absent' #569

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
5 changes: 0 additions & 5 deletions plugins/modules/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,11 +899,6 @@ def main():
module.fail_json(
msg="Error unmounting %s: %s" % (name, msg))

if os.path.exists(name):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change the behavior of state: absent.
But I don't think the rmdir logic should be skipped. Because it breaks backward compatibility.
If you want to skip it, how about adding keep_mountpoint or preserve_mountpoint to keep the mountpoint to avoid Directory not empty error instead of removing this section.

If this is set as true, you can skip rmdir section. Also, if the default value is set as false, to keep backward compatibility, you can set it to false by default.

try:
os.rmdir(name)
except (OSError, IOError) as e:
module.fail_json(msg="Error rmdir %s: %s" % (name, to_native(e)))
elif state == 'unmounted':
if ismount(name) or is_bind_mounted(module, linux_mounts, name):
if not module.check_mode:
Expand Down