diff --git a/lib/ansible/plugins/callback/actionable.py b/lib/ansible/plugins/callback/actionable.py index d738db0cda..d0127a36d1 100644 --- a/lib/ansible/plugins/callback/actionable.py +++ b/lib/ansible/plugins/callback/actionable.py @@ -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 ''' diff --git a/lib/ansible/plugins/callback/debug.py b/lib/ansible/plugins/callback/debug.py index 3d5969f648..247470e117 100644 --- a/lib/ansible/plugins/callback/debug.py +++ b/lib/ansible/plugins/callback/debug.py @@ -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 ''' diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index 23c10a73ec..03c5f495b5 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -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)) diff --git a/lib/ansible/plugins/callback/dense.py b/lib/ansible/plugins/callback/dense.py index 4694b76ada..0c120fce65 100644 --- a/lib/ansible/plugins/callback/dense.py +++ b/lib/ansible/plugins/callback/dense.py @@ -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" diff --git a/lib/ansible/plugins/callback/full_skip.py b/lib/ansible/plugins/callback/full_skip.py index fdb8a6d410..bc5b0dbfb2 100644 --- a/lib/ansible/plugins/callback/full_skip.py +++ b/lib/ansible/plugins/callback/full_skip.py @@ -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 ''' diff --git a/lib/ansible/plugins/callback/skippy.py b/lib/ansible/plugins/callback/skippy.py index bf7745cf27..92076cc146 100644 --- a/lib/ansible/plugins/callback/skippy.py +++ b/lib/ansible/plugins/callback/skippy.py @@ -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 ''' diff --git a/lib/ansible/plugins/callback/stderr.py b/lib/ansible/plugins/callback/stderr.py index fcf53850d2..9d8240cb1b 100644 --- a/lib/ansible/plugins/callback/stderr.py +++ b/lib/ansible/plugins/callback/stderr.py @@ -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 diff --git a/lib/ansible/utils/module_docs_fragments/default_callback.py b/lib/ansible/utils/module_docs_fragments/default_callback.py new file mode 100644 index 0000000000..9cca95e9fa --- /dev/null +++ b/lib/ansible/utils/module_docs_fragments/default_callback.py @@ -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 +"""