1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix for dnf groupinstall

Previous fix to group install introduced a different bug trying to
strip() group names at the wrong level.  This patch fixes that.

Fixes #3358
This commit is contained in:
Toshio Kuratomi 2016-11-04 08:37:21 -07:00 committed by Matt Clay
parent 3ec6722a21
commit 138f2cd847

View file

@ -304,14 +304,14 @@ def ensure(module, base, state, names):
filenames = [f.strip() for f in filenames] filenames = [f.strip() for f in filenames]
groups = [] groups = []
environments = [] environments = []
for group_spec in group_specs: for group_spec in (g.strip() for g in group_specs):
group = base.comps.group_by_pattern(group_spec) group = base.comps.group_by_pattern(group_spec)
if group: if group:
groups.append(group.strip()) groups.append(group)
else: else:
environment = base.comps.environments_by_pattern(group_spec) environment = base.comps.environment_by_pattern(group_spec)
if environment: if environment:
environments.extend((e.id.strip() for e in environment)) environments.append(environment.id)
else: else:
module.fail_json( module.fail_json(
msg="No group {} available.".format(group_spec)) msg="No group {} available.".format(group_spec))
@ -376,11 +376,21 @@ def ensure(module, base, state, names):
module.fail_json( module.fail_json(
msg="Cannot remove paths -- please specify package name.") msg="Cannot remove paths -- please specify package name.")
installed = base.sack.query().installed()
for group in groups: for group in groups:
if installed.filter(name=group.name): try:
base.group_remove(group) base.group_remove(group)
except dnf.exceptions.CompsError:
# Group is already uninstalled.
pass
for envioronment in environments:
try:
base.environment_remove(environment)
except dnf.exceptions.CompsError:
# Environment is already uninstalled.
pass
installed = base.sack.query().installed()
for pkg_spec in pkg_specs: for pkg_spec in pkg_specs:
if installed.filter(name=pkg_spec): if installed.filter(name=pkg_spec):
base.remove(pkg_spec) base.remove(pkg_spec)