mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix behavior of urpmi module where it always return "changed"
even when a package is already installed, since urpmi will always return 0 wether it install or not.
This commit is contained in:
parent
1e4609343d
commit
9482815b71
1 changed files with 9 additions and 1 deletions
|
@ -90,6 +90,13 @@ def query_package(module, name):
|
|||
else:
|
||||
return False
|
||||
|
||||
def query_package_provides(module, name):
|
||||
|
||||
# rpm -q returns 0 if the package is installed,
|
||||
# 1 if it is not installed
|
||||
rc = os.system("rpm -q --provides %s >/dev/null" % (name))
|
||||
return rc == 0
|
||||
|
||||
|
||||
def update_package_db(module):
|
||||
rc = os.system("urpmi.update -a -q")
|
||||
|
@ -125,6 +132,7 @@ def install_packages(module, pkgspec, force=True, no_suggests=True):
|
|||
|
||||
packages = ""
|
||||
for package in pkgspec:
|
||||
if not query_package_provides(module, package):
|
||||
packages += "'%s' " % package
|
||||
|
||||
if len(packages) != 0:
|
||||
|
|
Loading…
Reference in a new issue