From 3e6a6b14fe7bed15b8dd86d74fcbe83a8a62aae4 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Tue, 6 Nov 2018 10:52:12 +1000 Subject: [PATCH] win_uri: stop output from mixing with module result --- changelogs/fragments/win_uri-junk-data.yaml | 2 ++ lib/ansible/modules/windows/win_uri.ps1 | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/win_uri-junk-data.yaml diff --git a/changelogs/fragments/win_uri-junk-data.yaml b/changelogs/fragments/win_uri-junk-data.yaml new file mode 100644 index 00000000000000..de591990efcf46 --- /dev/null +++ b/changelogs/fragments/win_uri-junk-data.yaml @@ -0,0 +1,2 @@ +bugfixes: +- win_uri - stop junk output from being returned to Ansible - https://github.com/ansible/ansible/issues/47998 diff --git a/lib/ansible/modules/windows/win_uri.ps1 b/lib/ansible/modules/windows/win_uri.ps1 index d927724aab5e7e..7c5ea736df1907 100644 --- a/lib/ansible/modules/windows/win_uri.ps1 +++ b/lib/ansible/modules/windows/win_uri.ps1 @@ -239,7 +239,7 @@ if ($return_content -or $dest) { $resp_st.Close() if ($return_content) { - $memory_st.Seek(0, [System.IO.SeekOrigin]::Begin) + $memory_st.Seek(0, [System.IO.SeekOrigin]::Begin) > $null $content_bytes = $memory_st.ToArray() $result.content = [System.Text.Encoding]::UTF8.GetString($content_bytes) if ($result.ContainsKey("content_type") -and $result.content_type -Match ($JSON_CANDIDATES -join '|')) { @@ -252,7 +252,7 @@ if ($return_content -or $dest) { } if ($dest) { - $memory_st.Seek(0, [System.IO.SeekOrigin]::Begin) + $memory_st.Seek(0, [System.IO.SeekOrigin]::Begin) > $null $changed = $true if (Test-AnsiblePath -Path $dest) { @@ -268,7 +268,7 @@ if ($return_content -or $dest) { $result.changed = $changed if ($changed -and (-not $check_mode)) { - $memory_st.Seek(0, [System.IO.SeekOrigin]::Begin) + $memory_st.Seek(0, [System.IO.SeekOrigin]::Begin) > $null $file_stream = [System.IO.File]::Create($dest) try { $memory_st.CopyTo($file_stream)