From 2f83a5b084289a80cd6b7b6e1c9424e32575b1af Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 17 May 2026 20:38:33 +1200 Subject: [PATCH] selective callback plugin: align host names in stats output (#12065) * fix(selective): align host names in stats output Co-Authored-By: Claude Sonnet 4.6 * changelog(selective): add fragment for PR #12065 Co-Authored-By: Claude Sonnet 4.6 --------- 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 969e553bfe..b4b7813eea 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']}" ) self._display.display(colorize(msg, color))