From 7304fd6b3c783e714d38680a911162223d2fabf8 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 11:09:29 +0200 Subject: [PATCH] [PR #12065/2f83a5b0 backport][stable-12] selective callback plugin: align host names in stats output (#12071) selective callback plugin: align host names in stats output (#12065) * fix(selective): align host names in stats output * changelog(selective): add fragment for PR #12065 --------- (cherry picked from commit 2f83a5b084289a80cd6b7b6e1c9424e32575b1af) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 --- .../fragments/12065-selective-callback-stats-alignment.yml | 2 ++ plugins/callback/selective.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/12065-selective-callback-stats-alignment.yml diff --git a/changelogs/fragments/12065-selective-callback-stats-alignment.yml b/changelogs/fragments/12065-selective-callback-stats-alignment.yml new file mode 100644 index 0000000000..52854bebc7 --- /dev/null +++ b/changelogs/fragments/12065-selective-callback-stats-alignment.yml @@ -0,0 +1,2 @@ +bugfixes: + - selective callback plugin - align host names in stats output by padding to the longest name (https://github.com/ansible-collections/community.general/issues/8797, https://github.com/ansible-collections/community.general/pull/12065). diff --git a/plugins/callback/selective.py b/plugins/callback/selective.py index ba9a9f939a..9969cb25b9 100644 --- a/plugins/callback/selective.py +++ b/plugins/callback/selective.py @@ -228,6 +228,7 @@ class CallbackModule(CallbackBase): self._print_task("STATS") hosts = sorted(stats.processed.keys()) + max_len = max((len(h) for h in hosts), default=0) for host in hosts: s = stats.summarize(host) @@ -239,8 +240,8 @@ class CallbackModule(CallbackBase): color = "ok" msg = ( - f"{host} : ok={s['ok']}\tchanged={s['changed']}\tfailed={s['failures']}\tunreachable=" - f"{s['unreachable']}\trescued={s['rescued']}\tignored={s['ignored']}" + f"{host.ljust(max_len)} : ok={s['ok']}\tchanged={s['changed']}\tfailed={s['failures']}\t" + f"unreachable={s['unreachable']}\trescued={s['rescued']}\tignored={s['ignored']}" ) print(colorize(msg, color))