From 6e201948bc7a7166d82b7cb99b24500e17088285 Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Fri, 12 Feb 2016 15:51:48 +0100 Subject: [PATCH] dnf module: package not installed with state=latest dnf: name=PACKAGE state=latest is reponsible for two use cases: - to install a package if not already installed. - to update the package to the latest if already installed. The latter use cases is not handled properly as base.upgrade does not throw dnf.exceptions.MarkingError if a package is not installed. Setting base.conf.best = True ensures a package is installed or updated to the latest when calling base.install. Sign-off: jsilhan@redhat.com Sign-off: jchaloup@redhat.com --- lib/ansible/modules/extras/packaging/os/dnf.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/extras/packaging/os/dnf.py b/lib/ansible/modules/extras/packaging/os/dnf.py index 2dd63c525e..dfb733b2a9 100644 --- a/lib/ansible/modules/extras/packaging/os/dnf.py +++ b/lib/ansible/modules/extras/packaging/os/dnf.py @@ -281,11 +281,10 @@ def ensure(module, base, state, names): # If not already installed, try to install. base.group_install(group, const.GROUP_PACKAGE_TYPES) for pkg_spec in pkg_specs: - try: - base.upgrade(pkg_spec) - except dnf.exceptions.MarkingError: - # If not already installed, try to install. - _mark_package_install(module, base, pkg_spec) + # best effort causes to install the latest package + # even if not previously installed + base.conf.best = True + base.install(pkg_spec) else: # state == absent