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
dbf5a57a
Commit
dbf5a57a
authored
Dec 02, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1683 from bcoca/template_override
Template override
parents
a74cae20
d7f38d07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
lib/ansible/utils/template.py
+11
-1
test/jinja2_overrides.tpl
+10
-0
No files found.
lib/ansible/utils/template.py
View file @
dbf5a57a
...
@@ -31,7 +31,7 @@ import pwd
...
@@ -31,7 +31,7 @@ import pwd
# TODO: refactor this file
# TODO: refactor this file
_LISTRE
=
re
.
compile
(
r"(\w+)\[(\d+)\]"
)
_LISTRE
=
re
.
compile
(
r"(\w+)\[(\d+)\]"
)
JINJA2_OVERRIDE
=
'#jinja2:'
def
_varFindLimitSpace
(
basedir
,
vars
,
space
,
part
,
depth
):
def
_varFindLimitSpace
(
basedir
,
vars
,
space
,
part
,
depth
):
''' limits the search space of space to part
''' limits the search space of space to part
...
@@ -275,6 +275,16 @@ def template_from_file(basedir, path, vars):
...
@@ -275,6 +275,16 @@ def template_from_file(basedir, path, vars):
raise
errors
.
AnsibleError
(
"unable to process as utf-8:
%
s"
%
realpath
)
raise
errors
.
AnsibleError
(
"unable to process as utf-8:
%
s"
%
realpath
)
except
:
except
:
raise
errors
.
AnsibleError
(
"unable to read
%
s"
%
realpath
)
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
(
':'
)
setattr
(
environment
,
key
.
strip
(),
val
.
strip
())
t
=
environment
.
from_string
(
data
)
t
=
environment
.
from_string
(
data
)
vars
=
vars
.
copy
()
vars
=
vars
.
copy
()
try
:
try
:
...
...
test/jinja2_overrides.tpl
0 → 100644
View file @
dbf5a57a
#jinja2: variable_end_string: @@, variable_start_string: @@
{% raw %}
if this succeeds you should see '{{ ansible_hostname }}' with the hostname on the line above
if this fails you should see '@@ ansible_hostname @@' with the hostname on the line beneath
{% endraw %}
@@ ansible_hostname @@
{{ ansible_hostname }}
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