From 5ea260f44bac1d2c7b220d205c1f10e426aaa9db Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Nov 2012 10:33:43 -0500 Subject: [PATCH] fix case in which file is created and backup is requested but fails, not it just doesn't attempt to backup the missing file Signed-off-by: Brian Coca --- library/lineinfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/lineinfile b/library/lineinfile index 060256174b..abec9cc3cf 100755 --- a/library/lineinfile +++ b/library/lineinfile @@ -143,7 +143,7 @@ def present(module, dest, regexp, line, insertafter, create, backup): changed = True if changed: - if backup: + if backup and os.path.exists(dest): module.backup_local(dest) f = open(dest, 'wb') f.writelines(lines)