1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

iso_extract - invoke run_command passing list (#3805) (#3812)

* iso_extract - invoke run_command passing list

* added changelog fragment

(cherry picked from commit d60edc4ac1)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2021-11-30 06:53:00 +01:00 committed by GitHub
parent 9ddb75a3a2
commit d6a09ada98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- iso_extract - calling ``run_command`` with arguments as ``list`` instead of ``str`` (https://github.com/ansible-collections/community.general/pull/3805).

View file

@ -85,11 +85,6 @@ import os.path
import shutil
import tempfile
try: # python 3.3+
from shlex import quote
except ImportError: # older python
from pipes import quote
from ansible.module_utils.basic import AnsibleModule
@ -154,9 +149,9 @@ def main():
# Use 7zip when we have a binary, otherwise try to mount
if binary:
cmd = '%s x "%s" -o"%s" %s' % (binary, image, tmp_dir, ' '.join([quote(f) for f in extract_files]))
cmd = [binary, 'x', image, '-o%s' % tmp_dir] + extract_files
else:
cmd = 'mount -o loop,ro "%s" "%s"' % (image, tmp_dir)
cmd = [module.get_bin_path('mount'), '-o', 'loop,ro', image, tmp_dir]
rc, out, err = module.run_command(cmd)
if rc != 0:
@ -201,7 +196,7 @@ def main():
result['changed'] = True
finally:
if not binary:
module.run_command('umount "%s"' % tmp_dir)
module.run_command([module.get_bin_path('umount'), tmp_dir])
shutil.rmtree(tmp_dir)