From 9dc78e1e3b9a044014289140495ad2dc940fb0e6 Mon Sep 17 00:00:00 2001 From: Matteo Pompili <6500688+matpompili@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:47:13 -0700 Subject: [PATCH 1/3] If the return code contains #CLIXML (like a progress bar) remove it --- plugins/connection/aws_ssm.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/connection/aws_ssm.py b/plugins/connection/aws_ssm.py index 5c2d6d57788..84fd307bb98 100644 --- a/plugins/connection/aws_ssm.py +++ b/plugins/connection/aws_ssm.py @@ -748,6 +748,10 @@ def _post_process(self, stdout, mark_begin): # output to keep will be before the mark stdout = stdout[:stdout.rfind(mark_begin)] # fmt: skip + # If the return code contains #CLIXML (like a progress bar) remove it + clixml_filter = re.compile(r'#<\sCLIXML\s') + stdout = clixml_filter.sub('', stdout) + # If it looks like JSON remove any newlines if stdout.startswith("{"): stdout = stdout.replace("\n", "") From 11e6341663f2176230f290137e176ba39285205a Mon Sep 17 00:00:00 2001 From: Matteo Pompili Date: Tue, 23 Apr 2024 08:33:22 -0700 Subject: [PATCH 2/3] lint with black --- plugins/connection/aws_ssm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/connection/aws_ssm.py b/plugins/connection/aws_ssm.py index 84fd307bb98..0dae5092876 100644 --- a/plugins/connection/aws_ssm.py +++ b/plugins/connection/aws_ssm.py @@ -749,8 +749,8 @@ def _post_process(self, stdout, mark_begin): stdout = stdout[:stdout.rfind(mark_begin)] # fmt: skip # If the return code contains #CLIXML (like a progress bar) remove it - clixml_filter = re.compile(r'#<\sCLIXML\s') - stdout = clixml_filter.sub('', stdout) + clixml_filter = re.compile(r"#<\sCLIXML\s") + stdout = clixml_filter.sub("", stdout) # If it looks like JSON remove any newlines if stdout.startswith("{"): From ec2830fb2c7a30fe8cee5d6329207919f177c7b5 Mon Sep 17 00:00:00 2001 From: Matteo Pompili <6500688+matpompili@users.noreply.github.com> Date: Fri, 26 Apr 2024 11:18:14 -0700 Subject: [PATCH 3/3] added changelog fragment --- changelogs/fragments/20240426_fix_ssm_clixml.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/20240426_fix_ssm_clixml.yml diff --git a/changelogs/fragments/20240426_fix_ssm_clixml.yml b/changelogs/fragments/20240426_fix_ssm_clixml.yml new file mode 100644 index 00000000000..50f4d0af289 --- /dev/null +++ b/changelogs/fragments/20240426_fix_ssm_clixml.yml @@ -0,0 +1,2 @@ +bugfixes: + - ssm - strip Powershell CLIXML from stdout (https://github.com/ansible-collections/community.aws/issues/1952). \ No newline at end of file