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)

* iso_extract - invoke run_command passing list

* added changelog fragment
This commit is contained in:
Alexei Znamensky 2021-11-30 18:04:55 +13:00 committed by GitHub
parent cb0ade4323
commit d60edc4ac1
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 shutil
import tempfile 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 from ansible.module_utils.basic import AnsibleModule
@ -154,9 +149,9 @@ def main():
# Use 7zip when we have a binary, otherwise try to mount # Use 7zip when we have a binary, otherwise try to mount
if binary: 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: 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) rc, out, err = module.run_command(cmd)
if rc != 0: if rc != 0:
@ -201,7 +196,7 @@ def main():
result['changed'] = True result['changed'] = True
finally: finally:
if not binary: if not binary:
module.run_command('umount "%s"' % tmp_dir) module.run_command([module.get_bin_path('umount'), tmp_dir])
shutil.rmtree(tmp_dir) shutil.rmtree(tmp_dir)