diff --git a/changelogs/fragments/346-boot-linux.yml b/changelogs/fragments/346-boot-linux.yml new file mode 100644 index 0000000..c0a2ae5 --- /dev/null +++ b/changelogs/fragments/346-boot-linux.yml @@ -0,0 +1,3 @@ +--- +bugfix: + - mount - Handle ``boot`` option on Linux, NetBSD and OpenBSD correctly (https://github.com/ansible-collections/ansible.posix/issues/364). diff --git a/plugins/modules/mount.py b/plugins/modules/mount.py index 144f46e..b17c0a9 100644 --- a/plugins/modules/mount.py +++ b/plugins/modules/mount.py @@ -840,11 +840,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. diff --git a/tests/integration/targets/mount/tasks/main.yml b/tests/integration/targets/mount/tasks/main.yml index 58eace8..25d0ca0 100644 --- a/tests/integration/targets/mount/tasks/main.yml +++ b/tests/integration/targets/mount/tasks/main.yml @@ -467,6 +467,25 @@ that: - mount_info['opts'] == 'rw,user,async,noauto' + - name: Unmount FS + ansible.posix.mount: + 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: no + 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