[PATCH 1/9] ansible_cfg: add diy callback support
Daniel Gomez <[email protected]>
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
From: Daniel Gomez <[email protected]> Add support for the community.general.diy callback plugin as an alternative to the dense callback. The DIY callback provides a dense-equivalent output format while enabling human-readable failure reporting and customizable task output formatting. Key features: - Clean task headers without asterisk spam - Human-readable failure messages with stderr/stdout output - Colorized output for different message types - Smart default: disables display_ok_hosts for DIY callback - Full integration with kdevops kconfig system This allows users to get clean, readable output while maintaining the compact format of the dense callback, with the added benefit of seeing actual failure details instead of cryptic JSON metadata. Disable deprecation warning messages for Debian community.general.diy callback plugin users. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]> --- kconfigs/Kconfig.ansible_cfg | 12 ++++++++-- .../roles/ansible_cfg/templates/ansible.cfg.j2 | 27 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/kconfigs/Kconfig.ansible_cfg b/kconfigs/Kconfig.ansible_cfg index a5812995..430c0e4c 100644 --- a/kconfigs/Kconfig.ansible_cfg +++ b/kconfigs/Kconfig.ansible_cfg @@ -69,6 +69,11 @@ config ANSIBLE_CFG_CALLBACK_PLUGIN_DENSE help Dense: https://docs.ansible.com/ansible/latest/collections/community/general/dense_callback.html +config ANSIBLE_CFG_CALLBACK_PLUGIN_DIY + bool "Ansible DIY Callback Plugin" + help + DIY: https://docs.ansible.com/ansible/latest/collections/community/general/diy_callback.html + config ANSIBLE_CFG_CALLBACK_PLUGIN_CUSTOM bool "Custom Ansible Callback Plugin" help @@ -90,6 +95,7 @@ config ANSIBLE_CFG_CALLBACK_PLUGIN_STRING output yaml default "debug" if ANSIBLE_CFG_CALLBACK_PLUGIN_DEBUG default "dense" if ANSIBLE_CFG_CALLBACK_PLUGIN_DENSE + default "community.general.diy" if ANSIBLE_CFG_CALLBACK_PLUGIN_DIY default ANSIBLE_CFG_CALLBACK_PLUGIN_CUSTOM_NAME if ANSIBLE_CFG_CALLBACK_PLUGIN_CUSTOM config ANSIBLE_CFG_CALLBACK_PLUGIN_CHECK_MODE_MARKERS @@ -111,7 +117,8 @@ config ANSIBLE_CFG_CALLBACK_PLUGIN_DISPLAY_FAILED_STDERR config ANSIBLE_CFG_CALLBACK_PLUGIN_DISPLAY_OK_HOSTS bool "display_ok_hosts" output yaml - default y + default y if !ANSIBLE_CFG_CALLBACK_PLUGIN_DIY + default n if ANSIBLE_CFG_CALLBACK_PLUGIN_DIY help Toggle to control displaying ‘ok’ task/host results in a task. https://docs.ansible.com/ansible/latest/collections/community/general/dense_callback.html#parameter-display_ok_hosts @@ -154,7 +161,8 @@ endmenu config ANSIBLE_CFG_DEPRECATION_WARNINGS bool "deprecation_warnings" output yaml - default y + default y if !ANSIBLE_CFG_CALLBACK_PLUGIN_DIY + default n if ANSIBLE_CFG_CALLBACK_PLUGIN_DIY help Toggle to control the showing of deprecation warnings https://docs.ansible.com/ansible/latest/reference_appendices/config.html#deprecation-warnings diff --git a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 index e968bb32..f3cc1797 100644 --- a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 +++ b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 @@ -12,6 +12,33 @@ interpreter_python = {{ ansible_cfg_interpreter_python_string }} forks = {{ ansible_cfg_forks }} enable_task_debugger = {{ ansible_cfg_task_debugger }} inventory = {{ ansible_cfg_inventory }} + +{% if ansible_cfg_callback_plugin_string == 'community.general.diy' %} +[callback_diy] +playbook_on_play_start_msg = PLAY: {{ '{{' }} ansible_callback_diy.play.name | default('') | upper {{ '}}' }} +playbook_on_play_start_msg_color = bright blue +playbook_on_task_start_msg = TASK: {{ '{{' }} ansible_callback_diy.task.name | default('') {{ '}}' }} +playbook_on_task_start_msg_color = yellow +runner_on_start_msg = start: [{{ '{{' }} ansible_callback_diy.host.name | default('host') {{ '}}' }}] +runner_on_start_msg_color = yellow +runner_on_ok_msg = ok: [{{ '{{' }} ansible_callback_diy.result.host | default('host') {{ '}}' }}] +runner_on_ok_msg_color = green +runner_on_changed_msg = changed: [{{ '{{' }} ansible_callback_diy.result.host | default('host') {{ '}}' }}] +runner_on_changed_msg_color = bright yellow +runner_on_failed_msg = FAILED: [{{ '{{' }} ansible_callback_diy.result.host | default('host') {{ '}}' }}] => {{ '{{' }} msg | default('') {{ '}}' }}{{ '{%' }} if stderr is defined and stderr | length > 0 {{ '%}' }} STDERR: {{ '{{' }} stderr {{ '}}' }}{{ '{%' }} endif {{ '%}' }}{{ '{%' }} if stdout is defined and stdout | length > 0 {{ '%}' }} STDOUT: {{ '{{' }} stdout {{ '}}' }}{{ '{%' }} endif {{ '%}' }} +runner_on_failed_msg_color = bright red +runner_on_skipped_msg = skipped: [{{ '{{' }} ansible_callback_diy.result.host | default('host') {{ '}}' }}] +runner_on_skipped_msg_color = cyan +runner_on_unreachable_msg = UNREACHABLE: [{{ '{{' }} ansible_callback_diy.result.host | default('host') {{ '}}' }}] +runner_on_unreachable_msg_color = bright magenta +playbook_on_stats_msg = PLAYBOOK SUMMARY + ================ + STATUS OK CHANGED FAILED HOST + {{ '{%' }} for host in ansible_callback_diy.stats.processed.keys() | sort {{ '%}' }} + {{ '{%' }} set status = "UNREACHABLE" if host in ansible_callback_diy.stats.dark | default({}) else "FAILED" if host in ansible_callback_diy.stats.failures | default({}) else "OK" {{ '%}' }}{{ '{{' }} "%-12s" | format(status) {{ '}}' }} {{ '{{' }} "%3d" | format(ansible_callback_diy.stats.ok.get(host, 0)) {{ '}}' }} {{ '{{' }} "%3d" | format(ansible_callback_diy.stats.changed.get(host, 0)) {{ '}}' }} {{ '{{' }} "%3d" | format(ansible_callback_diy.stats.failures.get(host, 0)) {{ '}}' }} {{ '{{' }} host {{ '}}' }} + {{ '{%' }} endfor {{ '%}' }} +playbook_on_stats_msg_color = bright green +{% endif %} {% if ansible_facts['distribution'] == 'openSUSE' %} [connection] retries = {{ ansible_cfg_reconnection_retries }} -- 2.50.1