From 138f2cd847369512b8852d0832a34a8c7cff04d0 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 4 Nov 2016 08:37:21 -0700 Subject: [PATCH] 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 --- .../modules/extras/packaging/os/dnf.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/extras/packaging/os/dnf.py b/lib/ansible/modules/extras/packaging/os/dnf.py index c77503f488..74b83ae9d1 100644 --- a/lib/ansible/modules/extras/packaging/os/dnf.py +++ b/lib/ansible/modules/extras/packaging/os/dnf.py @@ -304,14 +304,14 @@ def ensure(module, base, state, names): filenames = [f.strip() for f in filenames] groups = [] 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) if group: - groups.append(group.strip()) + groups.append(group) else: - environment = base.comps.environments_by_pattern(group_spec) + environment = base.comps.environment_by_pattern(group_spec) if environment: - environments.extend((e.id.strip() for e in environment)) + environments.append(environment.id) else: module.fail_json( msg="No group {} available.".format(group_spec)) @@ -376,11 +376,21 @@ def ensure(module, base, state, names): module.fail_json( msg="Cannot remove paths -- please specify package name.") - installed = base.sack.query().installed() for group in groups: - if installed.filter(name=group.name): + try: 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: if installed.filter(name=pkg_spec): base.remove(pkg_spec)