Merge pull request #365 from copyrights/last_wins

mount: remove boot exception if defaults in opts

SUMMARY

There is no need for an exception on defaults option when adding noauto. Mount is implemented as last win.
from mount(8):
       If you want to override mount options from /etc/fstab, you have to use the -o option:

          mount device|dir -o options

       and then the mount options from the command line will be appended to the list of options from /etc/fstab. This default behaviour can be changed using the --options-mode command-line option. The usual behavior is that the last
       option wins if there are conflicting ones.


Fixes #364
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME


ansible.posix.mount

ADDITIONAL INFORMATION

Reviewed-by: Hideki Saito <saito@fgrep.org>
This commit is contained in:
softwarefactory-project-zuul[bot] 2024-10-04 06:21:14 +00:00 committed by GitHub
commit 9cf2d8cc48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 5 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- mount - Handle ``boot`` option on Linux, NetBSD and OpenBSD correctly (https://github.com/ansible-collections/ansible.posix/issues/364).

View file

@ -850,11 +850,8 @@ def main():
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")
elif not module.params['boot']:
args['boot'] = 'no'
if 'defaults' in opts:
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'defaults'.")
else:
opts.append('noauto')
args['opts'] = ','.join(opts)
opts.append('noauto')
args['opts'] = ','.join(opts)
# If fstab file does not exist, we first need to create it. This mainly
# happens when fstab option is passed to the module.

View file

@ -472,6 +472,25 @@
path: /tmp/myfs
state: absent
- name: Mount the FS with noauto option and defaults
ansible.posix.mount:
path: /tmp/myfs
src: /tmp/myfs.img
fstype: ext3
state: mounted
boot: false
register: mount_info
- name: Assert the mount without noauto was successful
ansible.builtin.assert:
that:
- "'noauto' in mount_info['opts'].split(',')"
- name: Unmount FS
ansible.posix.mount:
path: /tmp/myfs
state: absent
- name: Remove the test FS
ansible.builtin.file:
path: '{{ item }}'