diff options
author | Toshio Kuratomi <a.badger@gmail.com> | 2016-11-04 08:37:21 -0700 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2016-11-04 09:06:10 -0700 |
commit | f9b97726da5d7fb6bdfbc4f056301495bc948588 (patch) | |
tree | 79292f91187933f3110b33383dbcef0a3fd36680 /packaging/os | |
parent | a1dcbf9ce50c19c21b0aa47891b1512c9abec3fc (diff) | |
download | ansible-modules-extras-f9b97726da5d7fb6bdfbc4f056301495bc948588.tar.gz |
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
Diffstat (limited to 'packaging/os')
-rw-r--r-- | packaging/os/dnf.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/packaging/os/dnf.py b/packaging/os/dnf.py index 504a9dac..98616da8 100644 --- a/packaging/os/dnf.py +++ b/packaging/os/dnf.py @@ -297,14 +297,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)) @@ -369,11 +369,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) |