From 438ed70a4373f1035ae90a042bc745791b40fa76 Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Mon, 2 May 2016 17:50:42 +0200 Subject: [PATCH 1/2] Restore Ansible 2.0 compatibility for includes --- lib/ansible/playbook/helpers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py index 608f3ee503b..5ee979ed642 100644 --- a/lib/ansible/playbook/helpers.py +++ b/lib/ansible/playbook/helpers.py @@ -114,8 +114,7 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h # 3. the included file name contains no variables, and has no loop is_static = t.static or \ C.DEFAULT_TASK_INCLUDES_STATIC or \ - (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC) or \ - not templar._contains_vars(t.args.get('_raw_params')) and t.loop is None + (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC) if is_static: if t.loop is not None: From 5ee38617b995a38f7b7cc79fa47decaadd037f80 Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Mon, 2 May 2016 18:00:43 +0200 Subject: [PATCH 2/2] Treat "static: yes/no" with higher priority than "task_includes_static" in ansible.cfg --- lib/ansible/playbook/helpers.py | 13 +++++++------ lib/ansible/playbook/task_include.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py index 5ee979ed642..ee7d9228010 100644 --- a/lib/ansible/playbook/helpers.py +++ b/lib/ansible/playbook/helpers.py @@ -108,13 +108,14 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h all_vars = variable_manager.get_vars(loader=loader, play=play, task=t) templar = Templar(loader=loader, variables=all_vars) - # check to see if this include is static, which can be true if: - # 1. the user set the 'static' option to true + # check to see if this include is dynamic or static: + # 1. the user has set the 'static' option to false or true # 2. one of the appropriate config options was set - # 3. the included file name contains no variables, and has no loop - is_static = t.static or \ - C.DEFAULT_TASK_INCLUDES_STATIC or \ - (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC) + if t.static is not None: + is_static = t.static + else: + is_static = C.DEFAULT_TASK_INCLUDES_STATIC or \ + (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC) if is_static: if t.loop is not None: diff --git a/lib/ansible/playbook/task_include.py b/lib/ansible/playbook/task_include.py index 4b1d2c098b8..14fe36c3a18 100644 --- a/lib/ansible/playbook/task_include.py +++ b/lib/ansible/playbook/task_include.py @@ -41,7 +41,7 @@ class TaskInclude(Task): # ================================================================================= # ATTRIBUTES - _static = FieldAttribute(isa='bool', default=False) + _static = FieldAttribute(isa='bool', default=None) @staticmethod def load(data, block=None, role=None, task_include=None, variable_manager=None, loader=None):