From eb349cb2017ebfecf68487b3c68fb47a15772ee8 Mon Sep 17 00:00:00 2001 From: Phil Nelson Date: Thu, 8 Jun 2017 22:47:21 -0600 Subject: [PATCH] Template parent include path before finding its dirname (#23202) Given parent include path "{{ var | default('path/file.yml') }}" os.path.dirname(parent_include_path) yields {{ var | default('path/ which is incorrect in itself but also causes templating errors due to unbalanced quotes. Fix both problems by templating parent include path before finding its dirname. --- lib/ansible/playbook/helpers.py | 2 +- lib/ansible/playbook/included_file.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py index 7b500de44a..c347a80713 100644 --- a/lib/ansible/playbook/helpers.py +++ b/lib/ansible/playbook/helpers.py @@ -169,7 +169,7 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h if not isinstance(parent_include, TaskInclude): parent_include = parent_include._parent continue - parent_include_dir = templar.template(os.path.dirname(parent_include.args.get('_raw_params'))) + parent_include_dir = os.path.dirname(templar.template(parent_include.args.get('_raw_params'))) if cumulative_path is None: cumulative_path = parent_include_dir elif not os.path.isabs(cumulative_path): diff --git a/lib/ansible/playbook/included_file.py b/lib/ansible/playbook/included_file.py index 5784ea0650..b9f7b3a25d 100644 --- a/lib/ansible/playbook/included_file.py +++ b/lib/ansible/playbook/included_file.py @@ -101,7 +101,7 @@ class IncludedFile: if not isinstance(parent_include, TaskInclude): parent_include = parent_include._parent continue - parent_include_dir = templar.template(os.path.dirname(parent_include.args.get('_raw_params'))) + parent_include_dir = os.path.dirname(templar.template(parent_include.args.get('_raw_params'))) if cumulative_path is None: cumulative_path = parent_include_dir elif not os.path.isabs(cumulative_path):