diff --git a/lib/ansible/modules/packaging/os/dnf.py b/lib/ansible/modules/packaging/os/dnf.py index feba39344f..cc8e7cdff2 100644 --- a/lib/ansible/modules/packaging/os/dnf.py +++ b/lib/ansible/modules/packaging/os/dnf.py @@ -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 diff --git a/test/integration/targets/dnf/tasks/dnf.yml b/test/integration/targets/dnf/tasks/dnf.yml index bfbd7a3ca9..a3496560ff 100644 --- a/test/integration/targets/dnf/tasks/dnf.yml +++ b/test/integration/targets/dnf/tasks/dnf.yml @@ -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: