From 59407cf2cb0353dc93ece7ab91b4a9bb7600e523 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 (cherry picked from commit af96cba7e1e125a52f923ab8d3a8ba0c3fa45e7a) --- 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 844f8ee3867..c7c22119a50 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 @@ -123,7 +124,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):