From af96cba7e1e125a52f923ab8d3a8ba0c3fa45e7a Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 16 Jan 2017 13:04:55 -0600 Subject: [PATCH] Fix for bug in Conditional for older jinja2 versions Fixes #20309 --- lib/ansible/playbook/conditional.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/conditional.py b/lib/ansible/playbook/conditional.py index fba5c4ff8c..79369cef12 100644 --- a/lib/ansible/playbook/conditional.py +++ b/lib/ansible/playbook/conditional.py @@ -22,6 +22,7 @@ __metaclass__ = type import ast import re +from jinja2.compiler import generate from jinja2.exceptions import UndefinedError from ansible.compat.six import text_type @@ -152,7 +153,7 @@ class Conditional: presented = "{%% if %s %%} True {%% else %%} False {%% endif %%}" % conditional res = e._parse(presented, None, None) - res = e._generate(res, None, None, defer_init=True) + res = generate(res, e, None, None) parsed = ast.parse(res, mode='exec') class CleansingNodeVisitor(ast.NodeVisitor):