mount module creates fstab entry even if it cannot mount a volume #1252

I’m just getting started with Ansible and I wanted to dip my toe in on a couple of easier bugs.

https://github.com/ansible/ansible-modules-core/issues/1252

This request is looking to change the ‘mount’ process to remove the fstab entry on mount failure. This is a pretty easy change, but before a pull request is entered I wanted to make sure the workflow in the bug is the one you want followed for this use case or if you feel the entry should stay in the fstab file regardless.

I think the suggested workflow is correct. If someone wants to add to fstab without the mount point or volume being present they can use present or absent for state.

If the state is mounted or unmounted and the mount/unmount fails, fstab should not be altered.

Looking over the code, the documentation, and the code comments there seems to be a disconnect around what to do for each state.

The Documentation for state:

absent = remove from fstab, DO remove mount point, do NOT unmount ( removing an active mount point isn’t possible )
present = add to fstab, do NOT create mount point, do NOT mount
mounted = add to fstab, create mount point, mount
unmounted = remove from fstab, unmount

The Code Comments for state:

absent = remove from fstab, unmount
present = add to fstab ( no mention of creating the mount point )
mounted = add to fstab, create mount point (if needed), mount (remount if existing changed)
unmounted = do NOT remove from fstab, unmount

The Code actions for state:

absent = remove from fstab, unmount, remove mount point
present = add to fstab (this does not create a mount point so subsequent commands or reboots could error on this line)
mounted = create mount point (if needed), add to fstab, mount (remount if existing and changed)
unmounted = unmount (this leaves the fstab file unchanged. subsequent commands or reboots will remount this)

The code is easy to change, but I’m looking for input on the right actions. My suggestion is to follow most of the documented actions ( I can correct the docs at the same time ).

absent = remove from fstab
present = add to fstab
mounted = add to fstab, create mount point (if needed), mount (remount is existing and changed)
unmount = remove from fstab, unmount, remove mount point

thoughts?

For mounted and unmounted

@blackreed9, your proposal seems sensible.

Just to close the loop on this one, a pull request was filed yesterday.

https://github.com/ansible/ansible-modules-core/pull/1283

-JD