From 0480b44f508751df9a4dd1903baf9adf3491b6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannig=20Perr=C3=A9?= Date: Mon, 23 Nov 2015 16:58:24 +0100 Subject: [PATCH 1/2] Allow debug var parameter to accept a list or dict. Fix https://github.com/ansible/ansible/issues/13252 --- lib/ansible/plugins/action/debug.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/action/debug.py b/lib/ansible/plugins/action/debug.py index 5a5a805e746..d3d46124406 100644 --- a/lib/ansible/plugins/action/debug.py +++ b/lib/ansible/plugins/action/debug.py @@ -41,9 +41,13 @@ class ActionModule(ActionBase): # FIXME: move the LOOKUP_REGEX somewhere else elif 'var' in self._task.args: # and not utils.LOOKUP_REGEX.search(self._task.args['var']): results = self._templar.template(self._task.args['var'], convert_bare=True) - if results == self._task.args['var']: - results = "VARIABLE IS NOT DEFINED!" - result[self._task.args['var']] = results + if type(self._task.args['var']) in (list, dict): + # If var is a list or dict, use the type as key to display + result[str(type(self._task.args['var']))] = results + else: + if results == self._task.args['var']: + results = "VARIABLE IS NOT DEFINED!" + result[self._task.args['var']] = results else: result['msg'] = 'here we are' From 5fa49a9ad87b75a789cdc8c9aa7b69b8bdf17c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannig=20Perr=C3=A9?= Date: Mon, 23 Nov 2015 22:04:55 +0100 Subject: [PATCH 2/2] Use to_unicode instead of str() --- lib/ansible/plugins/action/debug.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/action/debug.py b/lib/ansible/plugins/action/debug.py index d3d46124406..a024e28b01d 100644 --- a/lib/ansible/plugins/action/debug.py +++ b/lib/ansible/plugins/action/debug.py @@ -19,7 +19,7 @@ __metaclass__ = type from ansible.plugins.action import ActionBase from ansible.utils.boolean import boolean - +from ansible.utils.unicode import to_unicode class ActionModule(ActionBase): ''' Print statements during execution ''' @@ -43,7 +43,7 @@ class ActionModule(ActionBase): results = self._templar.template(self._task.args['var'], convert_bare=True) if type(self._task.args['var']) in (list, dict): # If var is a list or dict, use the type as key to display - result[str(type(self._task.args['var']))] = results + result[to_unicode(type(self._task.args['var']))] = results else: if results == self._task.args['var']: results = "VARIABLE IS NOT DEFINED!"