diff options
author | Brian Coca <brian.coca+git@gmail.com> | 2016-02-18 06:58:43 -0800 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2016-02-18 06:58:43 -0800 |
commit | 5552c049763c2f91f4f1f2f5b622408b563f423e (patch) | |
tree | 999fa8fcffaffdcbc2395eb6d76fbb873572aa1f /lib/ansible/plugins/action | |
parent | fe09f7ee49d01cf0258852fcd7d455c3a904f507 (diff) | |
download | ansible-5552c049763c2f91f4f1f2f5b622408b563f423e.tar.gz |
allow skipping debug depending on verbosity
Diffstat (limited to 'lib/ansible/plugins/action')
-rw-r--r-- | lib/ansible/plugins/action/debug.py | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/lib/ansible/plugins/action/debug.py b/lib/ansible/plugins/action/debug.py index f07d8ea5d0..7728d45cc2 100644 --- a/lib/ansible/plugins/action/debug.py +++ b/lib/ansible/plugins/action/debug.py @@ -26,7 +26,7 @@ class ActionModule(ActionBase): ''' Print statements during execution ''' TRANSFERS_FILES = False - VALID_ARGS = set(['msg', 'var']) + VALID_ARGS = set(['msg', 'var', 'verbosity']) def run(self, tmp=None, task_vars=None): if task_vars is None: @@ -41,26 +41,34 @@ class ActionModule(ActionBase): result = super(ActionModule, self).run(tmp, task_vars) - if 'msg' in self._task.args: - result['msg'] = self._task.args['msg'] + verbosity = 0 + # get task verbosity + if 'verbosity' in self._task.args: + verbosity = int(self._task.args['verbosity']) - elif 'var' in self._task.args: - try: - results = self._templar.template(self._task.args['var'], convert_bare=True, fail_on_undefined=True, bare_deprecated=False) - if results == self._task.args['var']: - raise AnsibleUndefinedVariable - except AnsibleUndefinedVariable: - results = "VARIABLE IS NOT DEFINED!" + if verbosity <= self._display.verbosity: + if 'msg' in self._task.args: + result['msg'] = self._task.args['msg'] - if type(self._task.args['var']) in (list, dict): - # If var is a list or dict, use the type as key to display - result[to_unicode(type(self._task.args['var']))] = results + elif 'var' in self._task.args: + try: + results = self._templar.template(self._task.args['var'], convert_bare=True, fail_on_undefined=True, bare_deprecated=False) + if results == self._task.args['var']: + raise AnsibleUndefinedVariable + except AnsibleUndefinedVariable: + results = "VARIABLE IS NOT DEFINED!" + + if type(self._task.args['var']) in (list, dict): + # If var is a list or dict, use the type as key to display + result[to_unicode(type(self._task.args['var']))] = results + else: + result[self._task.args['var']] = results else: - result[self._task.args['var']] = results - else: - result['msg'] = 'Hello world!' + result['msg'] = 'Hello world!' - # force flag to make debug output module always verbose - result['_ansible_verbose_always'] = True + # force flag to make debug output module always verbose + result['_ansible_verbose_always'] = True + else: + result['skipped'] = True return result |