unarchive - log errors from underlying commands (#75329)

* unarchive - log errors from underlying commands

When a command run by the module fails, log the errors if debugging is enabled.

* Use debug() method
This commit is contained in:
Sam Doran 2023-03-01 10:55:14 -05:00 committed by GitHub
parent a56428de11
commit 292c70368b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- unarchive - log errors from commands to assist in debugging (https://github.com/ansible/ansible/issues/64612)

View File

@ -337,6 +337,7 @@ class ZipArchive(object):
def _legacy_file_list(self):
rc, out, err = self.module.run_command([self.cmd_path, '-v', self.src])
if rc:
self.module.debug(err)
raise UnarchiveError('Neither python zipfile nor unzip can read %s' % self.src)
for line in out.splitlines()[3:-2]:
@ -417,6 +418,7 @@ class ZipArchive(object):
if self.include_files:
cmd.extend(self.include_files)
rc, out, err = self.module.run_command(cmd)
self.module.debug(err)
old_out = out
diff = ''
@ -745,6 +747,9 @@ class ZipArchive(object):
rc, out, err = self.module.run_command(cmd)
if rc == 0:
return True, None
self.module.debug(err)
return False, 'Command "%s" could not handle archive: %s' % (self.cmd_path, err)
@ -794,6 +799,7 @@ class TgzArchive(object):
locale = get_best_parsable_locale(self.module)
rc, out, err = self.module.run_command(cmd, cwd=self.b_dest, environ_update=dict(LANG=locale, LC_ALL=locale, LC_MESSAGES=locale, LANGUAGE=locale))
if rc != 0:
self.module.debug(err)
raise UnarchiveError('Unable to list files in the archive: %s' % err)
for filename in out.splitlines():