From 8bb9149a10863f87ed200b178062b2fb60b3520e Mon Sep 17 00:00:00 2001 From: YAEGASHI Takeshi Date: Mon, 24 Oct 2016 23:30:46 +0900 Subject: [PATCH] blockinfile: Add a newline at EOF when the file is newly created (#3174) Ref: #2687 --- lib/ansible/modules/extras/files/blockinfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/extras/files/blockinfile.py b/lib/ansible/modules/extras/files/blockinfile.py index 5302646858e..285a1097443 100755 --- a/lib/ansible/modules/extras/files/blockinfile.py +++ b/lib/ansible/modules/extras/files/blockinfile.py @@ -285,7 +285,7 @@ def main(): if lines: result = '\n'.join(lines) - if original and original.endswith('\n'): + if original is None or original.endswith('\n'): result += '\n' else: result = ''