ansible-collections / ansible.posix

Ansible Collection for Posix
Other
157 stars 152 forks source link

Add option to not remove mountpoint #331

Open Caligatio opened 2 years ago

Caligatio commented 2 years ago
SUMMARY

It would be useful to add the option to preserve the mountpoint directory when the state is set to absent.

ISSUE TYPE
COMPONENT NAME

ansible.posix.mount (plugins/modules/mount.py)

ADDITIONAL INFORMATION

I use network mounts over certain directories that varies from host to host. Nearly every time I specify the state as absent, it's because I want to ensure that a host is using the native filesystem rather than a network share. I want the underlying directory to still exist and rather not have to use a file task.

EDIT: I'm happy to do a PR don't have a good name for the option. It could also double as a flag to not have this task create directories needed for the mount.

saito-hideki commented 2 years ago

@Caligatio thank you for the feature request. I can't think of any good name for this option, but I agree with this request :)

NeodymiumFerBore commented 2 years ago

Hello. What about a boolean preserve_mountpoint, default to False so it keeps the actual behavior by default?

I could do a PR for this. @saito-hideki , do you know if there is any work in progress regarding this issue?

Caligatio commented 2 years ago

Despite my best intentions, I personally haven't started on it yet. It's ultimately implementers choice but manage_mointpoint might be worth considering as it could be used for both creation and deletion.