mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
return failed if a package couldn't be installed
For some reason, on my test mandriva, urpmi --force return 0 even when it cannot install a rpm. So we have to explicitely check if the package was properly installed with a loop
This commit is contained in:
parent
b7971a426c
commit
d66027ba7a
1 changed files with 8 additions and 1 deletions
|
@ -158,7 +158,14 @@ def install_packages(module, pkgspec, force=True, no_suggests=True):
|
||||||
cmd = ("%s --auto %s --quiet %s %s > /dev/null" % (URPMI_PATH, force_yes, no_suggests_yes, packages))
|
cmd = ("%s --auto %s --quiet %s %s > /dev/null" % (URPMI_PATH, force_yes, no_suggests_yes, packages))
|
||||||
|
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
if rc:
|
|
||||||
|
installed = True
|
||||||
|
for packages in pkgspec:
|
||||||
|
if not query_package_provides(module, package):
|
||||||
|
installed = False
|
||||||
|
|
||||||
|
# urpmi always have 0 for exit code if --force is used
|
||||||
|
if rc or not installed:
|
||||||
module.fail_json(msg="'urpmi %s' failed: %s" % (packages, err))
|
module.fail_json(msg="'urpmi %s' failed: %s" % (packages, err))
|
||||||
else:
|
else:
|
||||||
module.exit_json(changed=True, msg="%s present(s)" % packages)
|
module.exit_json(changed=True, msg="%s present(s)" % packages)
|
||||||
|
|
Loading…
Reference in a new issue