Adding the backup destination to the resut dictionary for lineinfile
This commit is contained in:
parent
590be8ac7d
commit
2157880029
1 changed files with 6 additions and 4 deletions
|
@ -260,13 +260,14 @@ def present(module, dest, regexp, line, insertafter, insertbefore, create,
|
||||||
msg = 'line added'
|
msg = 'line added'
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
backupdest = ""
|
||||||
if changed and not module.check_mode:
|
if changed and not module.check_mode:
|
||||||
if backup and os.path.exists(dest):
|
if backup and os.path.exists(dest):
|
||||||
module.backup_local(dest)
|
backupdest = module.backup_local(dest)
|
||||||
write_changes(module, lines, dest)
|
write_changes(module, lines, dest)
|
||||||
|
|
||||||
msg, changed = check_file_attrs(module, changed, msg)
|
msg, changed = check_file_attrs(module, changed, msg)
|
||||||
module.exit_json(changed=changed, msg=msg)
|
module.exit_json(changed=changed, msg=msg, backup=backupdest)
|
||||||
|
|
||||||
|
|
||||||
def absent(module, dest, regexp, line, backup):
|
def absent(module, dest, regexp, line, backup):
|
||||||
|
@ -294,16 +295,17 @@ def absent(module, dest, regexp, line, backup):
|
||||||
|
|
||||||
lines = filter(matcher, lines)
|
lines = filter(matcher, lines)
|
||||||
changed = len(found) > 0
|
changed = len(found) > 0
|
||||||
|
backupdest = ""
|
||||||
if changed and not module.check_mode:
|
if changed and not module.check_mode:
|
||||||
if backup:
|
if backup:
|
||||||
module.backup_local(dest)
|
backupdest = module.backup_local(dest)
|
||||||
write_changes(module, lines, dest)
|
write_changes(module, lines, dest)
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
msg = "%s line(s) removed" % len(found)
|
msg = "%s line(s) removed" % len(found)
|
||||||
|
|
||||||
msg, changed = check_file_attrs(module, changed, msg)
|
msg, changed = check_file_attrs(module, changed, msg)
|
||||||
module.exit_json(changed=changed, found=len(found), msg=msg)
|
module.exit_json(changed=changed, found=len(found), msg=msg, backup=backupdest)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in a new issue