From c29bbd265bebb98c14f61c3f30fb508440dc795d Mon Sep 17 00:00:00 2001 From: Hideki Saito Date: Tue, 8 Jun 2021 19:59:59 +0900 Subject: [PATCH] Modify boot option handling on BSD systems * Fixes #28 for BSD systems * Porting PR #196 to BSD systems Signed-off-by: Hideki Saito --- changelogs/fragments/203_boot_opt_for_bsd.yml | 4 ++++ plugins/modules/mount.py | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/203_boot_opt_for_bsd.yml diff --git a/changelogs/fragments/203_boot_opt_for_bsd.yml b/changelogs/fragments/203_boot_opt_for_bsd.yml new file mode 100644 index 0000000..0fdd50a --- /dev/null +++ b/changelogs/fragments/203_boot_opt_for_bsd.yml @@ -0,0 +1,4 @@ +--- +minor_changes: + - mount - Change behavior of ``boot`` option to set ``noauto`` on BSD nodes + (https://github.com/ansible-collections/ansible.posix/issues/28). diff --git a/plugins/modules/mount.py b/plugins/modules/mount.py index 5c4970d..5b22e43 100644 --- a/plugins/modules/mount.py +++ b/plugins/modules/mount.py @@ -96,7 +96,10 @@ options: - Only applies to Solaris and Linux systems. - For Solaris systems, C(true) will set C(yes) as the value of mount at boot in I(/etc/vfstab). - - For Linux systems, C(true) will add C(noauto) to mount options in I(/etc/fstab). + - For Linux, FreeBSD, NetBSD and OpenBSD systems, C(false) will add C(noauto) + to mount options in I(/etc/fstab). + - To avoid mount option conflicts, if C(noauto) specified in C(opts), + mount module will ignore C(boot). type: bool default: yes backup: @@ -722,10 +725,10 @@ def main(): for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'): if module.params[key] is not None: args[key] = module.params[key] - if platform.system().lower() == 'linux': - # Linux has 'noauto' as mount opts to handle mount on boot - # So boot option should manage 'noauto' in opts - # TODO: We need to support other system like *BSD that 'noauto' option available + if platform.system().lower() == 'linux' or platform.system().lower().endswith('bsd'): + # Linux, FreeBSD, NetBSD and OpenBSD have 'noauto' as mount option to + # handle mount on boot. To avoid mount option conflicts, if 'noauto' + # specified in 'opts', mount module will ignore 'boot'. opts = args['opts'].split(',') if 'noauto' in opts: args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")