From bbf212a268f0ec4396d225a1e9775c514c1c53cd Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 31 Oct 2013 19:35:50 -0400 Subject: [PATCH] Simplify the way the debug: var=varname plugin works. --- lib/ansible/runner/action_plugins/debug.py | 4 +++- lib/ansible/utils/__init__.py | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/ansible/runner/action_plugins/debug.py b/lib/ansible/runner/action_plugins/debug.py index aef4c5a7f4e..075b1cc76fd 100644 --- a/lib/ansible/runner/action_plugins/debug.py +++ b/lib/ansible/runner/action_plugins/debug.py @@ -49,9 +49,11 @@ class ActionModule(object): else: result = dict(msg=args['msg']) 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] exception = results[1] + print exception if exception is not None: intermediate = "failed to evaluate: %s" % str(exception) result[args['var']] = intermediate diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index f5f2de48335..5da1322c724 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -899,7 +899,7 @@ def is_list_of_strings(items): return False 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: 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? - 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): return not var.startswith("$") and not '{{' in var