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
bbf212a2
Commit
bbf212a2
authored
Oct 31, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the way the debug: var=varname plugin works.
parent
a078184a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
lib/ansible/runner/action_plugins/debug.py
+3
-1
lib/ansible/utils/__init__.py
+1
-5
No files found.
lib/ansible/runner/action_plugins/debug.py
View file @
bbf212a2
...
@@ -49,9 +49,11 @@ class ActionModule(object):
...
@@ -49,9 +49,11 @@ class ActionModule(object):
else
:
else
:
result
=
dict
(
msg
=
args
[
'msg'
])
result
=
dict
(
msg
=
args
[
'msg'
])
elif
'var'
in
args
:
elif
'var'
in
args
:
results
=
utils
.
safe_eval
(
args
[
'var'
],
inject
,
include_exceptions
=
True
,
template_call
=
True
)
results
=
utils
.
safe_eval
(
args
[
'var'
],
inject
,
include_exceptions
=
True
)
intermediate
=
results
[
0
]
intermediate
=
results
[
0
]
exception
=
results
[
1
]
exception
=
results
[
1
]
print
exception
if
exception
is
not
None
:
if
exception
is
not
None
:
intermediate
=
"failed to evaluate:
%
s"
%
str
(
exception
)
intermediate
=
"failed to evaluate:
%
s"
%
str
(
exception
)
result
[
args
[
'var'
]]
=
intermediate
result
[
args
[
'var'
]]
=
intermediate
...
...
lib/ansible/utils/__init__.py
View file @
bbf212a2
...
@@ -899,7 +899,7 @@ def is_list_of_strings(items):
...
@@ -899,7 +899,7 @@ def is_list_of_strings(items):
return
False
return
False
return
True
return
True
def
safe_eval
(
str
,
locals
=
None
,
include_exceptions
=
False
,
template_call
=
False
):
def
safe_eval
(
str
,
locals
=
None
,
include_exceptions
=
False
):
'''
'''
this is intended for allowing things like:
this is intended for allowing things like:
with_items: a_list_variable
with_items: a_list_variable
...
@@ -909,10 +909,6 @@ def safe_eval(str, locals=None, include_exceptions=False, template_call=False):
...
@@ -909,10 +909,6 @@ def safe_eval(str, locals=None, include_exceptions=False, template_call=False):
'''
'''
# FIXME: is there a more native way to do this?
# FIXME: is there a more native way to do this?
if
template_call
:
# for the debug module in Ansible, allow debug of the form foo.bar.baz versus Python dictionary form
str
=
template
.
template
(
None
,
"{{
%
s }}"
%
str
,
locals
)
def
is_set
(
var
):
def
is_set
(
var
):
return
not
var
.
startswith
(
"$"
)
and
not
'{{'
in
var
return
not
var
.
startswith
(
"$"
)
and
not
'{{'
in
var
...
...
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