# Adding, removing and updating mount options in /etc/fstab (3rdparty Module + Feature suggestion)

**URL:** <https://forum.ansible.com/t/adding-removing-and-updating-mount-options-in-etc-fstab-3rdparty-module-feature-suggestion/23582>\
**Category:** Ansible Developer\
**Created:** [January 28, 2017, 12:31am UTC](https://forum.ansible.com/t/adding-removing-and-updating-mount-options-in-etc-fstab-3rdparty-module-feature-suggestion/23582 "2017-01-28T00:31:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Lutonsky](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Lutonsky](https://forum.ansible.com/u/Michael_Lutonsky)\
**Post date:** [January 28, 2017, 12:31am UTC](https://forum.ansible.com/t/adding-removing-and-updating-mount-options-in-etc-fstab-3rdparty-module-feature-suggestion/23582/1 "2017-01-28T00:31:15Z")

</div>

Hi all,

ansibles mount-module[1] already offers almost everything you'd want to  
do with a mount point. Of course it is also able to set the whole list  
of mount options as a string (for example `rw,noatime`). But there is  
currently no native way of adding or removing only one option, while  
leaving the others as they are. Such a feature could be useful when a  
system is only partly managed by ansible, in addition to humans or some  
other configuration management tool. Also, when there are multiple roles  
adding or updating mount options, each role has to somehow ignore the  
options added by the others.

There are a few manageable ways to \_add\_ new options[2] using `when` and  
the python `str.find()`-methods. Removing options is harder, though. So  
we wrote a 3rd-party ansible module[3] to do this job:

&nbsp;&nbsp;&nbsp;&nbsp;# set the 'data' option to 'ordered' on the root mount  
&nbsp;&nbsp;&nbsp;&nbsp;- mountopts:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: /  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option: data  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: ordered

&nbsp;&nbsp;&nbsp;&nbsp;# remove the 'noatime' option from the home mount  
&nbsp;&nbsp;&nbsp;&nbsp;- mountopts:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: /home  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option: noatime  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: absent

It comes with a few examples, a test suite and instructions on how to  
include it into your project. Feedback is very welcome, either via mail  
or by opening a github issue.

Since the original mount-module is imho lacking this functionality, it  
would be great to incorporate the features of this module into the core  
one. So, before I start working on a PR for that: are there any opinions  
on that?

Best Regards  
Michael

[1]: [http://docs.ansible.com/ansible/mount\_module.html](http://docs.ansible.com/ansible/mount_module.html)  
[2]: [http://stackoverflow.com/a/25979548/2486196](http://stackoverflow.com/a/25979548/2486196)  
[3]: [https://github.com/Uberspace/ansible-mountopts](https://github.com/Uberspace/ansible-mountopts)
