Fix for creation and removal of swap record in fstab (fixes #42706, #31437 and #30090) (#42837)

This commit is contained in:
Jiri Tyr 2018-07-31 22:09:38 +01:00 committed by ansibot
commit c93f24b45b
3 changed files with 118 additions and 2 deletions

View file

@ -218,7 +218,13 @@ def set_mount(module, args):
) = line.split()
# Check if we found the correct line
if ld['name'] != escaped_args['name']:
if (
ld['name'] != escaped_args['name'] or (
# In the case of swap, check the src instead
'src' in args and
ld['name'] == 'none' and
ld['fstype'] == 'swap' and
ld['src'] != args['src'])):
to_write.append(line)
continue
@ -299,7 +305,13 @@ def unset_mount(module, args):
ld['passno']
) = line.split()
if ld['name'] != escaped_name:
if (
ld['name'] != escaped_name or (
# In the case of swap, check the src instead
'src' in args and
ld['name'] == 'none' and
ld['fstype'] == 'swap' and
ld['src'] != args['src'])):
to_write.append(line)
continue