From b73cddc48583b5fc4a42028385ac422c0f3d7305 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 7 Apr 2014 09:42:27 -0500 Subject: [PATCH] Revert "Fix #5679 again after recent changes in core" This reverts commit 2bfaacd17063ed52ceca53f55861acb7ff655c66. Fixes #6821 --- library/files/lineinfile | 5 +++-- .../roles/test_lineinfile/tasks/main.yml | 18 ------------------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/library/files/lineinfile b/library/files/lineinfile index 06e946f130b..f781911ccd1 100644 --- a/library/files/lineinfile +++ b/library/files/lineinfile @@ -351,8 +351,9 @@ def main(): if ins_bef is None and ins_aft is None: ins_aft = 'EOF' - # Replace the newline character with an actual newline. - line = params['line'].decode('string_escape') + # Replace the newline character with an actual newline. Don't replace + # escaped \\n, hence sub and not str.replace. + line = re.sub(r'\n', os.linesep, params['line']) present(module, dest, params['regexp'], line, ins_aft, ins_bef, create, backup, backrefs) diff --git a/test/integration/roles/test_lineinfile/tasks/main.yml b/test/integration/roles/test_lineinfile/tasks/main.yml index b8974b7edca..f59979473b9 100644 --- a/test/integration/roles/test_lineinfile/tasks/main.yml +++ b/test/integration/roles/test_lineinfile/tasks/main.yml @@ -209,21 +209,3 @@ that: - "result.stat.md5 == 'fef1d487711facfd7aa2c87d788c19d9'" - -- name: insert a multiple lines at the end of the file - lineinfile: dest={{output_dir}}/test.txt state=present line="This is a line\nwith \\\n character" insertafter="EOF" - register: result - -- name: assert that the multiple lines was inserted - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- stat: path={{output_dir}}/test.txt - register: result - -- name: assert test md5 matches after insert the multiple lines - assert: - that: - - "result.stat.md5 == 'c2510d5bc8fdef8e752b8f8e74c784c2'"