From ac66e4001cca09dc8717af6b1507b4daaa6651c7 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 12 Aug 2015 10:12:05 -0400 Subject: [PATCH] Fix for variable precedence with tasks/includes Fixes #11881 --- lib/ansible/playbook/task.py | 6 +++--- lib/ansible/plugins/strategies/__init__.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 7d45506e2d8..788c70b5681 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -212,19 +212,19 @@ class Task(Base, Conditional, Taggable, Become): return value def get_vars(self): - all_vars = self.vars.copy() + all_vars = dict() if self._block: all_vars.update(self._block.get_vars()) if self._task_include: all_vars.update(self._task_include.get_vars()) - #if isinstance(self.args, dict): - # all_vars.update(self.args) + all_vars.update(self.vars) if 'tags' in all_vars: del all_vars['tags'] if 'when' in all_vars: del all_vars['when'] + return all_vars def copy(self, exclude_block=False): diff --git a/lib/ansible/plugins/strategies/__init__.py b/lib/ansible/plugins/strategies/__init__.py index 0728750bdec..51b6bc06e0a 100644 --- a/lib/ansible/plugins/strategies/__init__.py +++ b/lib/ansible/plugins/strategies/__init__.py @@ -406,9 +406,9 @@ class StrategyBase: # set the vars for this task from those specified as params to the include for b in block_list: - temp_vars = b.vars.copy() + temp_vars = b._task_include.vars.copy() temp_vars.update(included_file._args.copy()) - b.vars = temp_vars + b._task_include.vars = temp_vars return block_list