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
5b3c82f4
Commit
5b3c82f4
authored
Nov 26, 2014
by
Brian Coca
Committed by
James Cammarata
Nov 26, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fine tuned lookup/templating errors
parent
e5344a71
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
6 deletions
+10
-6
lib/ansible/runner/lookup_plugins/flattened.py
+2
-2
lib/ansible/utils/__init__.py
+4
-2
lib/ansible/utils/template.py
+4
-2
No files found.
lib/ansible/runner/lookup_plugins/flattened.py
View file @
5b3c82f4
...
...
@@ -50,7 +50,7 @@ class LookupModule(object):
if
isinstance
(
term
,
basestring
):
# convert a variable to a list
term2
=
utils
.
listify_lookup_plugin_terms
(
term
,
self
.
basedir
,
inject
,
fail_on_undefined
=
False
)
term2
=
utils
.
listify_lookup_plugin_terms
(
term
,
self
.
basedir
,
inject
)
# but avoid converting a plain string to a list of one string
if
term2
!=
[
term
]:
term
=
term2
...
...
@@ -59,7 +59,7 @@ class LookupModule(object):
# if it's a list, check recursively for items that are a list
term
=
self
.
flatten
(
term
,
inject
)
ret
.
extend
(
term
)
else
:
else
:
ret
.
append
(
term
)
return
ret
...
...
lib/ansible/utils/__init__.py
View file @
5b3c82f4
...
...
@@ -1451,7 +1451,7 @@ def safe_eval(expr, locals={}, include_exceptions=False):
return
expr
def
listify_lookup_plugin_terms
(
terms
,
basedir
,
inject
,
fail_on_undefined
=
C
.
DEFAULT_UNDEFINED_VAR_BEHAVIOR
):
def
listify_lookup_plugin_terms
(
terms
,
basedir
,
inject
):
from
ansible.utils
import
template
...
...
@@ -1469,11 +1469,13 @@ def listify_lookup_plugin_terms(terms, basedir, inject, fail_on_undefined=C.DEFA
# if not already a list, get ready to evaluate with Jinja2
# not sure why the "/" is in above code :)
try
:
new_terms
=
template
.
template
(
basedir
,
"{{
%
s}}"
%
terms
,
inject
,
convert_bare
=
True
,
fail_on_undefined
=
fail_on_undefined
)
new_terms
=
template
.
template
(
basedir
,
terms
,
inject
,
convert_bare
=
True
,
fail_on_undefined
=
C
.
DEFAULT_UNDEFINED_VAR_BEHAVIOR
)
if
isinstance
(
new_terms
,
basestring
)
and
"{{"
in
new_terms
:
pass
else
:
terms
=
new_terms
except
errors
.
AnsibleUndefinedVariable
:
raise
except
jinja2
.
exceptions
.
UndefinedError
,
e
:
raise
errors
.
AnsibleUndefinedVariable
(
'undefined variable in items:
%
s'
%
e
)
except
:
...
...
lib/ansible/utils/template.py
View file @
5b3c82f4
...
...
@@ -86,12 +86,14 @@ JINJA2_ALLOWED_OVERRIDES = ['trim_blocks', 'lstrip_blocks', 'newline_sequence',
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
)
t
vars
=
kwargs
.
get
(
'vars'
,
None
)
if
instance
is
not
None
:
# safely catch run failures per #5059
try
:
ran
=
instance
.
run
(
*
args
,
inject
=
vars
,
**
kwargs
)
ran
=
instance
.
run
(
*
args
,
inject
=
tvars
,
**
kwargs
)
except
errors
.
AnsibleUndefinedVariable
:
raise
except
Exception
,
e
:
ran
=
None
if
ran
:
...
...
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