From 1998eddf8d5213e476973a39a0ee57db020941ec Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 2 Sep 2015 11:52:37 -0700 Subject: [PATCH] Keep newlines by default now. In v1, a trailing newline was kept if the parameter was passed as key=value. If the parameter was passed as yaml dict the trailing newline was discarded. Since key-value and yaml dict were unified in v2 we have to make a choice as to which behaviour we want. Decided that keeping trailing newlines by default made the most sense. Fixes #12200 Fixes #12199 --- lib/ansible/template/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index ce7bf3c8cb..b4259bba9f 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -206,7 +206,7 @@ class Templar: assert isinstance(variables, dict) self._available_variables = variables.copy() - def template(self, variable, convert_bare=False, preserve_trailing_newlines=False, fail_on_undefined=None, overrides=None, convert_data=True): + def template(self, variable, convert_bare=False, preserve_trailing_newlines=True, fail_on_undefined=None, overrides=None, convert_data=True): ''' Templates (possibly recursively) any given data as input. If convert_bare is set to True, the given data will be wrapped as a jinja2 variable ('{{foo}}') @@ -316,7 +316,7 @@ class Templar: else: raise AnsibleError("lookup plugin (%s) not found" % name) - def _do_template(self, data, preserve_trailing_newlines=False, fail_on_undefined=None, overrides=None): + def _do_template(self, data, preserve_trailing_newlines=True, fail_on_undefined=None, overrides=None): # For preserving the number of input newlines in the output (used # later in this method)