From 18469dbb3e3bf92492c141e8f685fc495f05111a Mon Sep 17 00:00:00 2001 From: dkjii Date: Fri, 2 Apr 2021 09:50:36 -0400 Subject: [PATCH 1/3] ansible.posix.mount: add absent_from_fstab option --- plugins/modules/mount.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/modules/mount.py b/plugins/modules/mount.py index e7ce7eefec..31ea269f77 100644 --- a/plugins/modules/mount.py +++ b/plugins/modules/mount.py @@ -78,9 +78,12 @@ if I(opts) is set, and the remount command fails, the module will error to prevent unexpected mount changes. Try using C(mounted) instead to work around this issue. + - C(absent_from_fstab) specifies that the device mount's entry will be + removed from I(fstab). This option does not unmount it or delete the + mountpoint. type: str required: true - choices: [ absent, mounted, present, unmounted, remounted ] + choices: [ absent, absent_from_fstab, mounted, present, unmounted, remounted ] fstab: description: - File to use instead of C(/etc/fstab). @@ -651,7 +654,7 @@ def main(): passno=dict(type='str', no_log=False), src=dict(type='path'), backup=dict(type='bool', default=False), - state=dict(type='str', required=True, choices=['absent', 'mounted', 'present', 'unmounted', 'remounted']), + state=dict(type='str', required=True, choices=['absent', 'absent_from_fstab', 'mounted', 'present', 'unmounted', 'remounted']), ), supports_check_mode=True, required_if=( @@ -734,7 +737,9 @@ def main(): name = module.params['path'] changed = False - if state == 'absent': + if state == 'absent_from_fstab': + name, changed = unset_mount(module, args) + elif state == 'absent': name, changed = unset_mount(module, args) if changed and not module.check_mode: From 20e294e0264647f4aa2078ad0eaf320ba2ee1879 Mon Sep 17 00:00:00 2001 From: dkjii Date: Fri, 2 Apr 2021 12:33:58 -0400 Subject: [PATCH 2/3] add changelog --- changelogs/fragments/166_mount_absent_fstab.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/166_mount_absent_fstab.yml diff --git a/changelogs/fragments/166_mount_absent_fstab.yml b/changelogs/fragments/166_mount_absent_fstab.yml new file mode 100644 index 0000000000..2f7400ccc4 --- /dev/null +++ b/changelogs/fragments/166_mount_absent_fstab.yml @@ -0,0 +1,2 @@ +minor_changes: +- mount - Add absent_from_fstab state From 553b0ea4f74c2c4e0d0d3252bc57b1dabed54913 Mon Sep 17 00:00:00 2001 From: dkjii-g <41760646+dkjii-g@users.noreply.github.com> Date: Fri, 2 Apr 2021 21:00:51 -0400 Subject: [PATCH 3/3] Update changelogs/fragments/166_mount_absent_fstab.yml Co-authored-by: Amin Vakil --- changelogs/fragments/166_mount_absent_fstab.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/166_mount_absent_fstab.yml b/changelogs/fragments/166_mount_absent_fstab.yml index 2f7400ccc4..be1132498c 100644 --- a/changelogs/fragments/166_mount_absent_fstab.yml +++ b/changelogs/fragments/166_mount_absent_fstab.yml @@ -1,2 +1,2 @@ minor_changes: -- mount - Add absent_from_fstab state + - mount - Add ``absent_from_fstab`` state (https://github.com/ansible-collections/ansible.posix/pull/166).