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
496f06c3
Commit
496f06c3
authored
May 19, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass variables to lookup function for those that want to use them.
parent
16709ecd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
lib/ansible/utils/template.py
+6
-2
No files found.
lib/ansible/utils/template.py
View file @
496f06c3
...
...
@@ -80,8 +80,10 @@ JINJA2_OVERRIDE='#jinja2:'
def
lookup
(
name
,
*
args
,
**
kwargs
):
from
ansible
import
utils
instance
=
utils
.
plugins
.
lookup_loader
.
get
(
name
.
lower
(),
basedir
=
kwargs
.
get
(
'basedir'
,
None
))
vars
=
kwargs
.
get
(
'vars'
,
None
)
if
instance
is
not
None
:
return
","
.
join
(
instance
.
run
(
*
args
,
inject
=
vars
,
**
kwargs
))
ran
=
instance
.
run
(
*
args
,
inject
=
vars
,
**
kwargs
)
return
","
.
join
(
ran
)
else
:
raise
errors
.
AnsibleError
(
"lookup plugin (
%
s) not found"
%
name
)
...
...
@@ -400,6 +402,7 @@ def template_from_file(basedir, path, vars):
loader
=
jinja2
.
FileSystemLoader
([
basedir
,
os
.
path
.
dirname
(
realpath
)])
def
my_lookup
(
*
args
,
**
kwargs
):
kwargs
[
'vars'
]
=
vars
return
lookup
(
*
args
,
basedir
=
basedir
,
**
kwargs
)
environment
=
jinja2
.
Environment
(
loader
=
loader
,
trim_blocks
=
True
,
extensions
=
_get_extensions
())
...
...
@@ -413,7 +416,8 @@ def template_from_file(basedir, path, vars):
except
:
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