From 6afe25d93e9bfe8059e7aa013b412984e272529d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Sat, 1 Dec 2018 22:06:05 +0100 Subject: [PATCH] Implement the change in behaviour mentioned in the previous commit (cherry picked from commit a4141cfa2e49973310bba8c0962ef82d66c35f29) --- lib/ansible/modules/files/lineinfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/files/lineinfile.py b/lib/ansible/modules/files/lineinfile.py index 7c6d7a978fb..746f163b2af 100644 --- a/lib/ansible/modules/files/lineinfile.py +++ b/lib/ansible/modules/files/lineinfile.py @@ -309,9 +309,9 @@ def present(module, dest, regexp, line, insertafter, insertbefore, create, if not b_new_line.endswith(b_linesep): b_new_line += b_linesep - # If no regexp was given and a line match is found anywhere in the file, + # If no regexp was given and no line match is found anywhere in the file, # insert the line appropriately if using insertbefore or insertafter - if regexp is None and m: + if regexp is None and m is None: # Insert lines if insertafter and insertafter != 'EOF':