dnf: fix TypeError when env/group failed
(cherry picked from commit de299ef77c
)
This commit is contained in:
parent
f64c55e58f
commit
5db6b61cf0
2 changed files with 11 additions and 23 deletions
|
@ -168,6 +168,7 @@ except ImportError:
|
|||
HAS_DNF = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.six import PY2
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
|
@ -349,7 +350,7 @@ def ensure(module, base, state, names, autoremove):
|
|||
for group_spec in (g.strip() for g in group_specs):
|
||||
group = base.comps.group_by_pattern(group_spec)
|
||||
if group:
|
||||
groups.append(group)
|
||||
groups.append(group.id)
|
||||
else:
|
||||
environment = base.comps.environment_by_pattern(group_spec)
|
||||
if environment:
|
||||
|
@ -365,18 +366,18 @@ def ensure(module, base, state, names, autoremove):
|
|||
# Install groups.
|
||||
for group in groups:
|
||||
try:
|
||||
base.group_install(group.id, dnf.const.GROUP_PACKAGE_TYPES)
|
||||
base.group_install(group, dnf.const.GROUP_PACKAGE_TYPES)
|
||||
except dnf.exceptions.Error as e:
|
||||
# In dnf 2.0 if all the mandatory packages in a group do
|
||||
# not install, an error is raised. We want to capture
|
||||
# this but still install as much as possible.
|
||||
failures.append((group, e))
|
||||
failures.append((group, to_native(e)))
|
||||
|
||||
for environment in environments:
|
||||
try:
|
||||
base.environment_install(environment, dnf.const.GROUP_PACKAGE_TYPES)
|
||||
except dnf.exceptions.Error as e:
|
||||
failures.append((group, e))
|
||||
failures.append((environment, to_native(e)))
|
||||
|
||||
# Install packages.
|
||||
for pkg_spec in pkg_specs:
|
||||
|
@ -389,12 +390,12 @@ def ensure(module, base, state, names, autoremove):
|
|||
for group in groups:
|
||||
try:
|
||||
try:
|
||||
base.group_upgrade(group.id)
|
||||
base.group_upgrade(group)
|
||||
except dnf.exceptions.CompsError:
|
||||
# If not already installed, try to install.
|
||||
base.group_install(group.id, dnf.const.GROUP_PACKAGE_TYPES)
|
||||
base.group_install(group, dnf.const.GROUP_PACKAGE_TYPES)
|
||||
except dnf.exceptions.Error as e:
|
||||
failures.append((group, e))
|
||||
failures.append((group, to_native(e)))
|
||||
|
||||
for environment in environments:
|
||||
try:
|
||||
|
@ -402,9 +403,9 @@ def ensure(module, base, state, names, autoremove):
|
|||
base.environment_upgrade(environment)
|
||||
except dnf.exceptions.CompsError:
|
||||
# If not already installed, try to install.
|
||||
base.environment_install(group, dnf.const.GROUP_PACKAGE_TYPES)
|
||||
base.environment_install(environment, dnf.const.GROUP_PACKAGE_TYPES)
|
||||
except dnf.exceptions.Error as e:
|
||||
failures.append((group, e))
|
||||
failures.append((environment, to_native(e)))
|
||||
|
||||
for pkg_spec in pkg_specs:
|
||||
# best effort causes to install the latest package
|
||||
|
@ -423,7 +424,7 @@ def ensure(module, base, state, names, autoremove):
|
|||
|
||||
for group in groups:
|
||||
try:
|
||||
base.group_remove(group.id)
|
||||
base.group_remove(group)
|
||||
except dnf.exceptions.CompsError:
|
||||
# Group is already uninstalled.
|
||||
pass
|
||||
|
|
|
@ -27,9 +27,6 @@
|
|||
failed_when: False
|
||||
register: rpm_result
|
||||
|
||||
- debug: var=dnf_result
|
||||
- debug: var=rpm_result
|
||||
|
||||
- name: verify uninstallation of sos
|
||||
assert:
|
||||
that:
|
||||
|
@ -60,9 +57,6 @@
|
|||
failed_when: False
|
||||
register: rpm_result
|
||||
|
||||
- debug: var=dnf_result
|
||||
- debug: var=rpm_result
|
||||
|
||||
- name: verify installation of sos
|
||||
assert:
|
||||
that:
|
||||
|
@ -221,9 +215,6 @@
|
|||
failed_when: False
|
||||
register: rpm_result
|
||||
|
||||
- debug: var=dnf_result
|
||||
- debug: var=rpm_result
|
||||
|
||||
- name: verify installation of sos in /
|
||||
assert:
|
||||
that:
|
||||
|
@ -250,8 +241,6 @@
|
|||
state: present
|
||||
register: dnf_result
|
||||
|
||||
- debug: var=dnf_result
|
||||
|
||||
- name: verify installation of the group
|
||||
assert:
|
||||
that:
|
||||
|
@ -330,8 +319,6 @@
|
|||
state: latest
|
||||
register: dnf_result
|
||||
|
||||
- debug: var=dnf_result
|
||||
|
||||
- name: verify installation of the group
|
||||
assert:
|
||||
that:
|
||||
|
|
Loading…
Reference in a new issue