Skip to content

Commit

Permalink
mount: remove boot exception if defaults in opts
Browse files Browse the repository at this point in the history
  • Loading branch information
copyrights authored and saito-hideki committed Oct 4, 2024
1 parent afa724b commit 2041e7f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/365-boot-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- mount - Handle ``boot`` option on Linux, NetBSD and OpenBSD correctly (https://github.com/ansible-collections/ansible.posix/issues/364).
7 changes: 2 additions & 5 deletions plugins/modules/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/targets/mount/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand Down

0 comments on commit 2041e7f

Please sign in to comment.