[PATCH RFC 5/8] ansible: add profile_tasks callback timing analysis support
Daniel Gomez <[email protected]>
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
From: Daniel Gomez <[email protected]> Add new Kconfig option ANSIBLE_CFG_CALLBACK_PLUGIN_PROFILE_TASKS to enable the ansible.posix.profile_tasks callback plugin. This provides timing analysis similar to systemd-analyze blame, showing task execution times and generating a TASKS RECAP section with the slowest tasks at the end of playbook execution. The option is disabled by default to maintain clean output for existing workflows, but can be enabled when performance analysis is needed. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]> --- kconfigs/Kconfig.ansible_cfg | 14 ++++++++++++++ playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/kconfigs/Kconfig.ansible_cfg b/kconfigs/Kconfig.ansible_cfg index 430c0e4c..c04532e8 100644 --- a/kconfigs/Kconfig.ansible_cfg +++ b/kconfigs/Kconfig.ansible_cfg @@ -156,6 +156,20 @@ config ANSIBLE_CFG_CALLBACK_PLUGIN_SHOW_TASK_PATH_ON_FAILURE the line number. This information is displayed automatically for every task when running with -vv or greater verbosity. https://docs.ansible.com/ansible/latest/collections/community/general/dense_callback.html#parameter-show_task_path_on_failure + +config ANSIBLE_CFG_CALLBACK_PLUGIN_PROFILE_TASKS + bool "Enable profile_tasks callback for timing analysis" + output yaml + default n + help + Enable the profile_tasks callback plugin to provide timing analysis + similar to systemd-analyze blame. This shows how long each task takes + to execute and provides a summary of the slowest tasks at the end. + + When enabled, this adds timing information to playbook execution + and generates a "TASKS RECAP" section showing execution times. + + https://docs.ansible.com/ansible/latest/collections/ansible/posix/profile_tasks_callback.html endmenu config ANSIBLE_CFG_DEPRECATION_WARNINGS diff --git a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 index c8981e09..f3f6c723 100644 --- a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 +++ b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 @@ -1,4 +1,7 @@ [defaults] +{% if ansible_cfg_callback_plugin_profile_tasks %} +callbacks_enabled = ansible.posix.profile_tasks, {{ ansible_cfg_callback_plugin_string }} +{% endif %} deprecation_warnings = {{ ansible_cfg_deprecation_warnings }} stdout_callback = {{ ansible_cfg_callback_plugin_string }} check_mode_markers = {{ ansible_cfg_callback_plugin_check_mode_markers }} @@ -39,6 +42,11 @@ playbook_on_stats_msg = PLAYBOOK SUMMARY {{ '{%' }} endfor {{ '%}' }} playbook_on_stats_msg_color = bright green {% endif %} +{% if ansible_cfg_callback_plugin_profile_tasks %} + +[callback_profile_tasks] +summary_only = true +{% endif %} {% if ansible_facts['distribution'] == 'openSUSE' %} [connection] retries = {{ ansible_cfg_reconnection_retries }} -- 2.50.1