aboutsummaryrefslogtreecommitdiff
path: root/ansible
diff options
context:
space:
mode:
Diffstat (limited to 'ansible')
-rw-r--r--ansible/action_plugins/merge_configs.py7
-rw-r--r--ansible/action_plugins/merge_yaml.py7
2 files changed, 10 insertions, 4 deletions
diff --git a/ansible/action_plugins/merge_configs.py b/ansible/action_plugins/merge_configs.py
index 67a7da1cd..09dc1d04e 100644
--- a/ansible/action_plugins/merge_configs.py
+++ b/ansible/action_plugins/merge_configs.py
@@ -169,9 +169,12 @@ class ActionModule(action.ActionBase):
os.path.join(self._loader._basedir, 'templates'),
os.path.dirname(source),
]
- self._templar.environment.loader.searchpath = searchpath
+ templar = self._templar.copy_with_new_env(searchpath=searchpath)
- result = self._templar.template(template_data)
+ # lstrip_blocks avoids Jinja2 block tags (e.g. {% if %}) leaving
+ # behind leading whitespace that glues adjacent lines together.
+ result = templar.template(
+ template_data, overrides=dict(lstrip_blocks=True))
fakefile = StringIO(result)
config.parse(fakefile)
fakefile.close()
diff --git a/ansible/action_plugins/merge_yaml.py b/ansible/action_plugins/merge_yaml.py
index d2c15eb70..f3ba8597b 100644
--- a/ansible/action_plugins/merge_yaml.py
+++ b/ansible/action_plugins/merge_yaml.py
@@ -109,9 +109,12 @@ class ActionModule(action.ActionBase):
os.path.join(self._loader._basedir, 'templates'),
os.path.dirname(source),
]
- self._templar.environment.loader.searchpath = searchpath
+ templar = self._templar.copy_with_new_env(searchpath=searchpath)
- template_data = self._templar.template(template_data)
+ # lstrip_blocks avoids Jinja2 block tags (e.g. {% if %}) leaving
+ # behind leading whitespace that glues adjacent lines together.
+ template_data = templar.template(
+ template_data, overrides=dict(lstrip_blocks=True))
result = yaml.safe_load(template_data)
return result or {}