ansible.posix.mount: add absent_from_fstab option

This commit is contained in:
dkjii 2021-04-02 09:50:36 -04:00
parent ecd5ad53e0
commit 18469dbb3e

View file

@ -78,9 +78,12 @@ options:
if I(opts) is set, and the remount command fails, the module will if I(opts) is set, and the remount command fails, the module will
error to prevent unexpected mount changes. Try using C(mounted) error to prevent unexpected mount changes. Try using C(mounted)
instead to work around this issue. 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 type: str
required: true required: true
choices: [ absent, mounted, present, unmounted, remounted ] choices: [ absent, absent_from_fstab, mounted, present, unmounted, remounted ]
fstab: fstab:
description: description:
- File to use instead of C(/etc/fstab). - File to use instead of C(/etc/fstab).
@ -651,7 +654,7 @@ def main():
passno=dict(type='str', no_log=False), passno=dict(type='str', no_log=False),
src=dict(type='path'), src=dict(type='path'),
backup=dict(type='bool', default=False), 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, supports_check_mode=True,
required_if=( required_if=(
@ -734,7 +737,9 @@ def main():
name = module.params['path'] name = module.params['path']
changed = False 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) name, changed = unset_mount(module, args)
if changed and not module.check_mode: if changed and not module.check_mode: