From 479e7df687040eb521aaebe76c2f8a5df1127e4d Mon Sep 17 00:00:00 2001 From: Aidan Houck <92699100+AidanHouck@users.noreply.github.com> Date: Wed, 11 Oct 2023 10:20:30 -0400 Subject: [PATCH] Fix callback/selective task print being long (#7374) * Fix callback/selective task print being long Compare against all text on the line rather than simply the task_name var, which does not include 3 formatting characters in the string * Add changelog fragment --------- Co-authored-by: Aidan Houck --- .../fragments/7374-fix-selective-callback-taskname-length.yml | 2 ++ plugins/callback/selective.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/7374-fix-selective-callback-taskname-length.yml diff --git a/changelogs/fragments/7374-fix-selective-callback-taskname-length.yml b/changelogs/fragments/7374-fix-selective-callback-taskname-length.yml new file mode 100644 index 0000000000..1c48f48e05 --- /dev/null +++ b/changelogs/fragments/7374-fix-selective-callback-taskname-length.yml @@ -0,0 +1,2 @@ +bugfixes: + - "selective callback plugin - fix length of task name lines in output always being 3 characters longer than desired (https://github.com/ansible-collections/community.general/pull/7374)." diff --git a/plugins/callback/selective.py b/plugins/callback/selective.py index 3ad36fb120..0696757837 100644 --- a/plugins/callback/selective.py +++ b/plugins/callback/selective.py @@ -106,8 +106,8 @@ class CallbackModule(CallbackBase): line_length = 120 if self.last_skipped: print() - msg = colorize("# {0} {1}".format(task_name, - '*' * (line_length - len(task_name))), 'bold') + line = "# {0} ".format(task_name) + msg = colorize("{0}{1}".format(line, '*' * (line_length - len(line))), 'bold') print(msg) def _indent_text(self, text, indent_level):