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
1e05688b
Commit
1e05688b
authored
Jul 03, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8026 from hfinucane/jinja-args
Support a whitelisted subset of jinja2 template options
parents
746f52c5
de64bbdc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
lib/ansible/utils/template.py
+14
-0
No files found.
lib/ansible/utils/template.py
View file @
1e05688b
...
...
@@ -80,6 +80,8 @@ class Flags:
FILTER_PLUGINS
=
None
_LISTRE
=
re
.
compile
(
r"(\w+)\[(\d+)\]"
)
JINJA2_OVERRIDE
=
'#jinja2:'
JINJA2_ALLOWED_OVERRIDES
=
[
'trim_blocks'
,
'lstrip_blocks'
,
'newline_sequence'
,
'keep_trailing_newline'
]
def
lookup
(
name
,
*
args
,
**
kwargs
):
from
ansible
import
utils
...
...
@@ -230,6 +232,18 @@ def template_from_file(basedir, path, vars, vault_password=None):
except
:
raise
errors
.
AnsibleError
(
"unable to read
%
s"
%
realpath
)
# Get jinja env overrides from template
if
data
.
startswith
(
JINJA2_OVERRIDE
):
eol
=
data
.
find
(
'
\n
'
)
line
=
data
[
len
(
JINJA2_OVERRIDE
):
eol
]
data
=
data
[
eol
+
1
:]
for
pair
in
line
.
split
(
','
):
(
key
,
val
)
=
pair
.
split
(
':'
)
key
=
key
.
strip
()
if
key
in
JINJA2_ALLOWED_OVERRIDES
:
setattr
(
environment
,
key
,
ast
.
literal_eval
(
val
.
strip
()))
environment
.
template_class
=
J2Template
try
:
t
=
environment
.
from_string
(
data
)
...
...
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