Repository: ansible/ansible

Issue:
mount documentation incorrectly specifies what "absent" and "unmounted" do
_From @maxrothman on August 5, 2015 15:19_

Issue Type: Bug Report (documentation)
Component Name: mount module

Ansible Version: 1.9.1

Summary:
Running the `mount` module with `state=unmounted` unmounts the device, but does not remove it from fstab. Running the mount module with `state=absent` both unmounts the device **and** removes it from fstab.

This conflicts with the [documentation](http://docs.ansible.com/ansible/mount_module.html):

> If `mounted` or `unmounted`, the device will be actively mounted or unmounted as needed and appropriately configured in fstab. `absent` and `present` only deal with fstab but will not affect current mounting.

The present functionality seems to be intended in `mount`'s code, specifically [here](https://github.com/ansible/ansible-modules-core/blob/devel/system/mount.py#L319) and [here](https://github.com/ansible/ansible-modules-core/blob/devel/system/mount.py#L335).

`mounted` and `present` appear to work as documented.


_Copied from original issue: ansible/ansible-modules-core#1869_


Discussion:
_From @bcoca on August 5, 2015 21:29_

i believe that in this context 'appropriately configured in fstab' means that it does get put into fstab if it does not exist, not that it is removed. But that probably can be clarified further.

Either way, "`absent` and `present` only deal with fstab but will not affect current mounting" is false, given that `absent` also unmounts the disk.

_From @denisgarci on December 4, 2015 13:3_

Hi, thank you for opening this issue. I agree the docs are confusing. Especially the `absent` one.

_From @SarsTW on March 22, 2016 10:19_

This paragraph is confusing.

_From @alaverty on May 19, 2016 7:10_

How do we remove something from the fstab without unmounting? 

For example I want to remove the /var partition from fstab and then reboot the server, when I use absent i get the error :

"msg": "Error unmounting /var: umount: /var: device is busy.

_From @blendmaster on May 23, 2016 16:42_

> How do we remove something from the fstab without unmounting? 

I also needed to do this. Ended up just using lineinfile for now.

_From @ansibot on August 1, 2016 3:11_

@grossws, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/jctanner/ansibullbot/blob/ISSUE_TRIAGE_CLASS/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

_From @ansibot on September 12, 2016 21:22_

@grossws, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

_From @ansibot on October 6, 2016 15:51_

@ansible, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

_From @ansibot on October 22, 2016 9:19_

@ansible, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

_From @ansibot on November 6, 2016 10:9_

@ansible, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_renotify_maintainer --->

_From @ansibot on November 22, 2016 10:17_

@ansible, ping. This issue is still waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: issue_renotify_maintainer --->
This issue has been open for over a year. Is it scheduled to be worked on anytime soon?
_From @ansibot on December 7, 2016 19:10_

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the <a href="http://docs.ansible.com/ansible/dev_guide/repomerge.html#move-issues-and-prs-to-new-repo">repomerge</a> page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

<!-- boilerplate: repomerge -->
any updates?

@maxrothman Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information. 

Here are the items we could not find in your description:
- component name

Please set the description of this issue with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE.md

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: issue_missing_data --->
cc @jtyr
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/system/mount.py b/lib/ansible/modules/system/mount.py
--- a/lib/ansible/modules/system/mount.py
+++ b/lib/ansible/modules/system/mount.py
@@ -58,13 +58,14 @@
   state:
     description:
       - If C(mounted), the device will be actively mounted and appropriately
-        configured in I(fstab).
-      - If C(unmounted), the device will be unmounted without changing I(fstab).
-      - C(absent) and C(present) only deal with I(fstab) but will not affect
-        current mounting.
-      - If specifying C(mounted) and the mount point is not present, the mount
+        configured in I(fstab). If the mount point is not present, the mount
         point will be created.
-      - Similarly, specifying C(absent) will remove the mount point directory.
+      - If C(unmounted), the device will be unmounted without changing I(fstab).
+      - C(present) only specifies that the device is to be configured in
+        I(fstab) and does not trigger or require a mount.
+      - C(absent) specifies that the device mount's entry will be removed from
+        I(fstab) and will also unmount the device and remove the mount
+        point.
     required: true
     choices: [ absent, mounted, present, unmounted ]
   fstab:


Test patch: