* try to capture better winrm/put_file error
fixes #70361
* Update lib/ansible/plugins/connection/winrm.py
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
Co-authored-by: Matt Davis <nitzmahone@users.noreply.github.com>
(cherry picked from commit 8789d7968d
)
This commit is contained in:
parent
5ea6de4e7d
commit
827c47d9bc
2 changed files with 11 additions and 2 deletions
2
changelogs/fragments/better_winrm_putfile_error.yml
Normal file
2
changelogs/fragments/better_winrm_putfile_error.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- winrm - preserve winrm forensic data on put_file failures
|
|
@ -616,9 +616,16 @@ class Connection(ConnectionBase):
|
||||||
if result.status_code != 0:
|
if result.status_code != 0:
|
||||||
raise AnsibleError(to_native(result.std_err))
|
raise AnsibleError(to_native(result.std_err))
|
||||||
|
|
||||||
put_output = json.loads(result.std_out)
|
try:
|
||||||
remote_sha1 = put_output.get("sha1")
|
put_output = json.loads(result.std_out)
|
||||||
|
except ValueError:
|
||||||
|
# stdout does not contain a valid response
|
||||||
|
stderr = to_bytes(result.std_err, encoding='utf-8')
|
||||||
|
if stderr.startswith(b"#< CLIXML"):
|
||||||
|
stderr = _parse_clixml(stderr)
|
||||||
|
raise AnsibleError('winrm put_file failed; \nstdout: %s\nstderr %s' % (to_native(result.std_out), to_native(stderr)))
|
||||||
|
|
||||||
|
remote_sha1 = put_output.get("sha1")
|
||||||
if not remote_sha1:
|
if not remote_sha1:
|
||||||
raise AnsibleError("Remote sha1 was not returned")
|
raise AnsibleError("Remote sha1 was not returned")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue