fixed issue with default callback inheritance (#30427)

* fixed issue with default callback inheritance

 - callbacks need to document same options as callbacks they inherit from to get them configured
 - since default is also used by many 3rd party callbacks for inheritance, making the code 'tolerate' the missing docs
   and fallback to using the direct constant to configure it's options.
pull/30437/head
Brian Coca 7 years ago committed by Toshio Kuratomi
parent 5d404af76e
commit 81fd67c10f

@ -14,6 +14,8 @@ DOCUMENTATION = '''
- Use this callback when you dont care about OK nor Skipped.
- This callback suppreses any non Failed or Changed status.
version_added: "2.1"
extends_documentation_fragment:
- default_callback
requirements:
- set as stdout callback in configuration
'''

@ -11,6 +11,8 @@ DOCUMENTATION = '''
description:
- Use this callback to sort though extensive debug output
version_added: "2.4"
extends_documentation_fragment:
- default_callback
requirements:
- set as stdout in configuration
'''

@ -12,27 +12,8 @@ DOCUMENTATION = '''
version_added: historical
description:
- This is the default output callback for ansible-playbook.
options:
show_skipped_hosts:
name: Show skipped hosts
description: "Toggle to control displaying skipped task/host results in a task"
default: True
env:
- name: DISPLAY_SKIPPED_HOSTS
ini:
- key: display_skipped_hosts
section: defaults
type: boolean
show_custom_stats:
name: Show custom stats
description: 'This adds the custom stats set via the set_stats plugin to the play recap'
default: False
env:
- name: ANSIBLE_SHOW_CUSTOM_STATS
ini:
- key: show_custom_stats
section: defaults
type: bool
extends_documentation_fragment:
- default_callback
requirements:
- set as stdout in configuration
'''
@ -118,9 +99,8 @@ class CallbackModule(CallbackBase):
self._display.display(msg, color=color)
def v2_runner_on_skipped(self, result):
if self._plugin_options['show_skipped_hosts']:
if self._plugin_options.get('show_skipped_hosts', C.DISPLAY_SKIPPED_HOSTS): # fallback on constants for inherited plugins missing docs
delegated_vars = result._result.get('_ansible_delegated_vars', None)
self._clean_results(result._result, result._task.action)
if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
@ -247,7 +227,7 @@ class CallbackModule(CallbackBase):
self._display.display(msg + " (item=%s) => %s" % (self._get_item(result._result), self._dump_results(result._result)), color=C.COLOR_ERROR)
def v2_runner_item_on_skipped(self, result):
if self._plugin_options['show_skipped_hosts']:
if self._plugin_options.get('show_skipped_hosts', C.DISPLAY_SKIPPED_HOSTS): # fallback on constants for inherited plugins missing docs
self._clean_results(result._result, result._task.action)
msg = "skipping: [%s] => (item=%s) " % (result._host.get_name(), self._get_item(result._result))
if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and '_ansible_verbose_override' not in result._result:
@ -286,7 +266,7 @@ class CallbackModule(CallbackBase):
self._display.display("", screen_only=True)
# print custom stats
if self._plugin_options['show_custom_stats'] and stats.custom:
if self._plugin_options.get('show_custom_stats', C.SHOW_CUSTOM_STATS) and stats.custom: # fallback on constants for inherited plugins missing docs
self._display.banner("CUSTOM STATS: ")
# per host
# TODO: come up with 'pretty format'
@ -307,11 +287,12 @@ class CallbackModule(CallbackBase):
self._display.banner("PLAYBOOK: %s" % basename(playbook._file_name))
if self._display.verbosity > 3:
if self._plugin_options is not None:
for option in dir(self._plugin_options):
# show CLI options
if self._options is not None:
for option in dir(self._options):
if option.startswith('_') or option in ['read_file', 'ensure_value', 'read_module']:
continue
val = getattr(self._plugin_options, option)
val = getattr(self._options, option)
if val:
self._display.vvvv('%s: %s' % (option, val))

@ -9,6 +9,8 @@ DOCUMENTATION = '''
callback: dense
type: stdout
short_description: minimal stdout output
extends_documentation_fragment:
- default_callback
description:
- When in verbose mode it will act the same as the default callback
version_added: "2.3"

@ -13,6 +13,8 @@ DOCUMENTATION = '''
description:
- Use this plugin when you dont care about any output for tasks that were completly skipped
version_added: "2.4"
extends_documentation_fragment:
- default_callback
requirements:
- set as stdout in configuation
'''

@ -13,6 +13,8 @@ DOCUMENTATION = '''
- set as main display callback
short_description: Ansible screen output that ignores skipped status
version_added: "2.0"
extends_documentation_fragment:
- default_callback
description:
- This callback does the same as the default except it does not output skipped host/task/item status
'''

@ -13,6 +13,8 @@ DOCUMENTATION = '''
- set as main display callback
short_description: Splits output, sending failed tasks to stderr
version_added: "2.4"
extends_documentation_fragment:
- default_callback
description:
- This is the stderr callback plugin, it behaves like the default callback plugin but sends error output to stderr.
- Also it does not output skipped host/task/item status

@ -0,0 +1,29 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
class ModuleDocFragment(object):
DOCUMENTATION = """
options:
show_skipped_hosts:
name: Show skipped hosts
description: "Toggle to control displaying skipped task/host results in a task"
default: True
env:
- name: DISPLAY_SKIPPED_HOSTS
ini:
- key: display_skipped_hosts
section: defaults
type: boolean
show_custom_stats:
name: Show custom stats
description: 'This adds the custom stats set via the set_stats plugin to the play recap'
default: False
env:
- name: ANSIBLE_SHOW_CUSTOM_STATS
ini:
- key: show_custom_stats
section: defaults
type: bool
"""
Loading…
Cancel
Save