From 393ea3293c550c220e40a539c1d8a5817d8fb490 Mon Sep 17 00:00:00 2001 From: Hans-Joachim Kliemeck <h0nIg@users.noreply.github.com> Date: Fri, 20 May 2016 10:25:10 +0200 Subject: [PATCH] blockinfile will always add newline at EOF (#2261) --- lib/ansible/modules/extras/files/blockinfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/extras/files/blockinfile.py b/lib/ansible/modules/extras/files/blockinfile.py index 37d89ca2c8..81834dfd2d 100644 --- a/lib/ansible/modules/extras/files/blockinfile.py +++ b/lib/ansible/modules/extras/files/blockinfile.py @@ -280,7 +280,9 @@ def main(): lines[n0:n0] = blocklines if lines: - result = '\n'.join(lines)+'\n' + result = '\n'.join(lines) + if original.endswith('\n'): + result += '\n' else: result = '' if original == result: