From 2041e7f918be45cf56ba4000518d5b06157c7df7 Mon Sep 17 00:00:00 2001 From: copyrights Date: Mon, 23 May 2022 22:21:11 +0200 Subject: [PATCH] mount: remove boot exception if defaults in opts --- changelogs/fragments/365-boot-linux.yml | 3 +++ plugins/modules/mount.py | 7 ++----- .../integration/targets/mount/tasks/main.yml | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/365-boot-linux.yml diff --git a/changelogs/fragments/365-boot-linux.yml b/changelogs/fragments/365-boot-linux.yml new file mode 100644 index 0000000000..ec88776882 --- /dev/null +++ b/changelogs/fragments/365-boot-linux.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - 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 fe9faff569..dadbd46fd5 100644 --- a/plugins/modules/mount.py +++ b/plugins/modules/mount.py @@ -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. diff --git a/tests/integration/targets/mount/tasks/main.yml b/tests/integration/targets/mount/tasks/main.yml index 15c6e897d7..bb916489a5 100644 --- a/tests/integration/targets/mount/tasks/main.yml +++ b/tests/integration/targets/mount/tasks/main.yml @@ -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 }}'