From 94bb204e294c00ce7d4ff206e8325de4934fd470 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 17:01:50 +0200 Subject: [PATCH] [PR #7374/479e7df6 backport][stable-6] Fix callback/selective task print being long (#7390) 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 (cherry picked from commit 479e7df687040eb521aaebe76c2f8a5df1127e4d) Co-authored-by: Aidan Houck <92699100+AidanHouck@users.noreply.github.com> --- .../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 526975bd2c..610bb4784e 100644 --- a/plugins/callback/selective.py +++ b/plugins/callback/selective.py @@ -115,8 +115,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):