mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-13 00:20:50 -07:00
Simplify the way the debug: var=varname plugin works.
This commit is contained in:
parent
a078184ae8
commit
bbf212a268
2 changed files with 4 additions and 6 deletions
|
@ -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
|
||||||
|
|
|
@ -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):
|
||||||
'''
|
'''
|
||||||
# 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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue