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
b9f15038
Commit
b9f15038
authored
Dec 04, 2014
by
Brian Coca
Committed by
James Cammarata
Dec 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge pull request #9715 from bcoca/listify_revert_errorhandling
Listify revert errorhandling
parent
ecdeed43
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
19 deletions
+9
-19
lib/ansible/runner/__init__.py
+4
-0
lib/ansible/utils/__init__.py
+1
-6
lib/ansible/utils/template.py
+2
-3
test/units/TestUtils.py
+2
-10
No files found.
lib/ansible/runner/__init__.py
View file @
b9f15038
...
...
@@ -733,6 +733,10 @@ class Runner(object):
result
=
utils
.
jsonify
(
dict
(
changed
=
False
,
skipped
=
True
))
self
.
callbacks
.
on_skipped
(
host
,
None
)
return
ReturnData
(
host
=
host
,
result
=
result
)
except
errors
.
AnsibleError
,
e
:
raise
except
Exception
,
e
:
raise
errors
.
AnsibleError
(
"Unexpected error while executing task:
%
s"
%
str
(
e
))
# strip out any jinja2 template syntax within
# the data returned by the lookup plugin
...
...
lib/ansible/utils/__init__.py
View file @
b9f15038
...
...
@@ -48,7 +48,6 @@ import sys
import
json
import
subprocess
import
contextlib
import
jinja2.exceptions
from
vault
import
VaultLib
...
...
@@ -1469,15 +1468,11 @@ def listify_lookup_plugin_terms(terms, basedir, inject):
# 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
,
terms
,
inject
,
convert_bare
=
True
,
fail_on_undefined
=
C
.
DEFAULT_UNDEFINED_VAR_BEHAVIOR
)
new_terms
=
template
.
template
(
basedir
,
"{{
%
s }}"
%
terms
,
inject
)
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
:
pass
...
...
lib/ansible/utils/template.py
View file @
b9f15038
...
...
@@ -89,13 +89,12 @@ def lookup(name, *args, **kwargs):
tvars
=
kwargs
.
get
(
'vars'
,
None
)
if
instance
is
not
None
:
# safely catch run failures per #5059
try
:
ran
=
instance
.
run
(
*
args
,
inject
=
tvars
,
**
kwargs
)
except
errors
.
Ansible
UndefinedVariable
:
except
errors
.
Ansible
Error
:
raise
except
Exception
,
e
:
ra
n
=
None
ra
ise
errors
.
AnsibleError
(
'Unexpected error in during lookup:
%
s'
%
e
)
if
ran
:
ran
=
","
.
join
(
ran
)
return
ran
...
...
test/units/TestUtils.py
View file @
b9f15038
...
...
@@ -566,17 +566,9 @@ class TestUtils(unittest.TestCase):
def
test_listify_lookup_plugin_terms
(
self
):
basedir
=
os
.
path
.
dirname
(
__file__
)
# Straight lookups
self
.
assertEqual
(
ansible
.
utils
.
listify_lookup_plugin_terms
(
'things'
,
basedir
,
dict
(
things
=
[])),
[])
self
.
assertEqual
(
ansible
.
utils
.
listify_lookup_plugin_terms
(
'things'
,
basedir
,
dict
(
things
=
[
'one'
,
'two'
])),
[
'one'
,
'two'
])
# Variable interpolation
self
.
assertEqual
(
ansible
.
utils
.
listify_lookup_plugin_terms
(
'things'
,
basedir
,
dict
(
things
=
[
'{{ foo }}'
,
'{{ bar }}'
],
foo
=
"hello"
,
bar
=
"world"
)),
[
'hello'
,
'world'
])
with
self
.
assertRaises
(
ansible
.
errors
.
AnsibleError
)
as
ex
:
ansible
.
utils
.
listify_lookup_plugin_terms
(
'things'
,
basedir
,
dict
(
things
=
[
'{{ foo }}'
,
'{{ bar_typo }}'
],
foo
=
"hello"
,
bar
=
"world"
))
self
.
assertTrue
(
"undefined variable in items: 'bar_typo'"
in
ex
.
exception
.
msg
)
#self.assertEqual(ansible.utils.listify_lookup_plugin_terms('things', basedir, dict(things=[])), [])
#self.assertEqual(ansible.utils.listify_lookup_plugin_terms('things', basedir, dict(things=['one', 'two'])), ['one', 'two'])
def
test_deprecated
(
self
):
sys_stderr
=
sys
.
stderr
...
...
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