mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-02 22:39:09 -07:00
Convert some run_command() string args to lists (#8264)
* Convert some run_command() string args to lists. * Change run_command with pipe and shell to Python code. * Add changelog. * Simplify syntax. Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
b48293ca31
commit
70adba8991
14 changed files with 144 additions and 144 deletions
|
@ -106,7 +106,7 @@ def _check_new_pkg(module, package, repository_path):
|
|||
|
||||
if os.path.isdir(repository_path):
|
||||
installp_cmd = module.get_bin_path('installp', True)
|
||||
rc, package_result, err = module.run_command("%s -l -MR -d %s" % (installp_cmd, repository_path))
|
||||
rc, package_result, err = module.run_command([installp_cmd, "-l", "-MR", "-d", repository_path])
|
||||
if rc != 0:
|
||||
module.fail_json(msg="Failed to run installp.", rc=rc, err=err)
|
||||
|
||||
|
@ -142,7 +142,7 @@ def _check_installed_pkg(module, package, repository_path):
|
|||
"""
|
||||
|
||||
lslpp_cmd = module.get_bin_path('lslpp', True)
|
||||
rc, lslpp_result, err = module.run_command("%s -lcq %s*" % (lslpp_cmd, package))
|
||||
rc, lslpp_result, err = module.run_command([lslpp_cmd, "-lcq", "%s*" % (package, )])
|
||||
|
||||
if rc == 1:
|
||||
package_state = ' '.join(err.split()[-2:])
|
||||
|
@ -173,7 +173,7 @@ def remove(module, installp_cmd, packages):
|
|||
|
||||
if pkg_check:
|
||||
if not module.check_mode:
|
||||
rc, remove_out, err = module.run_command("%s -u %s" % (installp_cmd, package))
|
||||
rc, remove_out, err = module.run_command([installp_cmd, "-u", package])
|
||||
if rc != 0:
|
||||
module.fail_json(msg="Failed to run installp.", rc=rc, err=err)
|
||||
remove_count += 1
|
||||
|
@ -202,8 +202,8 @@ def install(module, installp_cmd, packages, repository_path, accept_license):
|
|||
already_installed_pkgs = {}
|
||||
|
||||
accept_license_param = {
|
||||
True: '-Y',
|
||||
False: '',
|
||||
True: ['-Y'],
|
||||
False: [],
|
||||
}
|
||||
|
||||
# Validate if package exists on repository path.
|
||||
|
@ -230,7 +230,8 @@ def install(module, installp_cmd, packages, repository_path, accept_license):
|
|||
|
||||
else:
|
||||
if not module.check_mode:
|
||||
rc, out, err = module.run_command("%s -a %s -X -d %s %s" % (installp_cmd, accept_license_param[accept_license], repository_path, package))
|
||||
rc, out, err = module.run_command(
|
||||
[installp_cmd, "-a"] + accept_license_param[accept_license] + ["-X", "-d", repository_path, package])
|
||||
if rc != 0:
|
||||
module.fail_json(msg="Failed to run installp", rc=rc, err=err)
|
||||
installed_pkgs.append(package)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue