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 diff --git a/plugins/connection/aws_ssm.py b/plugins/connection/aws_ssm.py index 5c2d6d57788..0dae5092876 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", "")