Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
294451d0
Commit
294451d0
authored
Sep 09, 2013
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly handle variable issues when evaluating jinja2 when statements
Fixes #4025
parent
af139cd5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
lib/ansible/utils/__init__.py
+13
-2
lib/ansible/utils/template.py
+1
-1
No files found.
lib/ansible/utils/__init__.py
View file @
294451d0
...
...
@@ -170,8 +170,19 @@ def check_conditional(conditional, basedir, inject, fail_on_undefined=False, jin
# a Jinja2 evaluation that results in something Python can eval!
presented
=
"{
%%
if
%
s
%%
} True {
%%
else
%%
} False {
%%
endif
%%
}"
%
conditional
conditional
=
template
.
template
(
basedir
,
presented
,
inject
)
val
=
conditional
.
lstrip
()
.
rstrip
()
if
val
==
"True"
:
val
=
conditional
.
strip
()
if
val
==
presented
:
# the templating failed, meaning most likely a
# variable was undefined. If we happened to be
# looking for an undefined variable, return True,
# otherwise fail
if
conditional
.
find
(
"is undefined"
)
!=
-
1
:
return
True
elif
conditional
.
find
(
"is defined"
)
!=
-
1
:
return
False
else
:
raise
errors
.
AnsibleError
(
"error while evaluating conditional:
%
s"
%
conditional
)
elif
val
==
"True"
:
return
True
elif
val
==
"False"
:
return
False
...
...
lib/ansible/utils/template.py
View file @
294451d0
...
...
@@ -430,7 +430,7 @@ def template_from_file(basedir, path, vars):
raise
errors
.
AnsibleError
(
"unable to read
%
s"
%
realpath
)
# Get jinja env overrides from template
# Get jinja env overrides from template
if
data
.
startswith
(
JINJA2_OVERRIDE
):
eol
=
data
.
find
(
'
\n
'
)
line
=
data
[
len
(
JINJA2_OVERRIDE
):
eol
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment