ansible.posix
ansible.posix copied to clipboard
Handle multiple mounts on the same mount point.
SUMMARY
It’s an edge-case we hit recently of having multiple NFS shares mounted on the same mount point.
Tasks that use mount module with state absent would first unmount then try to remove the directory used as a mount point via rmdir.
In this case we get error like - Error rmdir /mnt/share: [Errno 39] Directory not empty: "/mnt/share”
Mutiple mounts on the same dir is situation best avoided and no one can say that’s a bug or that ansible is doing something wrong. Thus, I’m raising this as a feature request to improve the module with a check for other mounted filesystems at that path before the module tries to delete the directory.
ISSUE TYPE
- Feature Idea
COMPONENT NAME
Mount module (ansible.posix/plugins/modules/mount.py)
ADDITIONAL INFORMATION
Sensible default behaviour would be to unmount all that is mounted on the directory. Maybe add a flag to indicate if the operator doesn’t want all mounts at that directory to be unmounted.
- name: unmount old
mount:
state: absent
path: /mnt/share
Thank you for reporting this @phobot I have triaged this feature request. It is likely that it depends on the OS implementation of the management node, but I think that the function to care for such a situation is good to me. :)