1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-11 14:35:06 +00:00

Reformat everything.

This commit is contained in:
Felix Fontein 2025-11-01 12:08:41 +01:00
parent 3f2213791a
commit 340ff8586d
1008 changed files with 61301 additions and 58309 deletions

View file

@ -102,12 +102,12 @@ def _check_new_pkg(module, package, repository_path):
"""
if os.path.isdir(repository_path):
installp_cmd = module.get_bin_path('installp', True)
installp_cmd = module.get_bin_path("installp", True)
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)
if package == 'all':
if package == "all":
pkg_info = "All packages on dir"
return True, pkg_info
@ -138,12 +138,12 @@ def _check_installed_pkg(module, package, repository_path):
:return: Bool, package data.
"""
lslpp_cmd = module.get_bin_path('lslpp', True)
lslpp_cmd = module.get_bin_path("lslpp", True)
rc, lslpp_result, err = module.run_command([lslpp_cmd, "-lcq", f"{package}*"])
if rc == 1:
package_state = ' '.join(err.split()[-2:])
if package_state == 'not installed.':
package_state = " ".join(err.split()[-2:])
if package_state == "not installed.":
return False, None
else:
module.fail_json(msg="Failed to run lslpp.", rc=rc, err=err)
@ -154,7 +154,7 @@ def _check_installed_pkg(module, package, repository_path):
pkg_data = {}
full_pkg_data = lslpp_result.splitlines()
for line in full_pkg_data:
pkg_name, fileset, level = line.split(':')[0:3]
pkg_name, fileset, level = line.split(":")[0:3]
pkg_data[pkg_name] = fileset, level
return True, pkg_data
@ -199,7 +199,7 @@ def install(module, installp_cmd, packages, repository_path, accept_license):
already_installed_pkgs = {}
accept_license_param = {
True: ['-Y'],
True: ["-Y"],
False: [],
}
@ -228,7 +228,10 @@ def install(module, installp_cmd, packages, repository_path, accept_license):
else:
if not module.check_mode:
rc, out, err = module.run_command(
[installp_cmd, "-a"] + accept_license_param[accept_license] + ["-X", "-d", repository_path, package])
[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)
@ -239,17 +242,17 @@ def install(module, installp_cmd, packages, repository_path, accept_license):
if len(installed_pkgs) > 0:
installed_msg = f" Installed: {' '.join(installed_pkgs)}."
else:
installed_msg = ''
installed_msg = ""
if len(not_found_pkgs) > 0:
not_found_msg = f" Not found: {' '.join(not_found_pkgs)}."
else:
not_found_msg = ''
not_found_msg = ""
if len(already_installed_pkgs) > 0:
already_installed_msg = f" Already installed: {already_installed_pkgs}."
else:
already_installed_msg = ''
already_installed_msg = ""
if len(installed_pkgs) > 0:
changed = True
@ -264,28 +267,28 @@ def install(module, installp_cmd, packages, repository_path, accept_license):
def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(type='list', elements='str', required=True, aliases=['pkg']),
repository_path=dict(type='path'),
accept_license=dict(type='bool', default=False),
state=dict(type='str', default='present', choices=['absent', 'present']),
name=dict(type="list", elements="str", required=True, aliases=["pkg"]),
repository_path=dict(type="path"),
accept_license=dict(type="bool", default=False),
state=dict(type="str", default="present", choices=["absent", "present"]),
),
supports_check_mode=True,
)
name = module.params['name']
repository_path = module.params['repository_path']
accept_license = module.params['accept_license']
state = module.params['state']
name = module.params["name"]
repository_path = module.params["repository_path"]
accept_license = module.params["accept_license"]
state = module.params["state"]
installp_cmd = module.get_bin_path('installp', True)
installp_cmd = module.get_bin_path("installp", True)
if state == 'present':
if state == "present":
if repository_path is None:
module.fail_json(msg="repository_path is required to install package")
changed, msg = install(module, installp_cmd, name, repository_path, accept_license)
elif state == 'absent':
elif state == "absent":
changed, msg = remove(module, installp_cmd, name)
else:
@ -294,5 +297,5 @@ def main():
module.exit_json(changed=changed, msg=msg)
if __name__ == '__main__':
if __name__ == "__main__":
main()