summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2022-09-29 19:55:51 -0400
committerGitHub <noreply@github.com>2022-09-29 16:55:51 -0700
commit45abd5b685104d4fa0d5a6501456b5a5372dfeef (patch)
tree7fdf7d6a5b98ef5f38669e122205cbebaaa50d37 /lib
parent551ddebeab451c1f158e4ef8b656d60ff57689be (diff)
downloadansible-45abd5b685104d4fa0d5a6501456b5a5372dfeef.tar.gz
[2.13] apt - fix failure when package is not installed and only_upgrade=True (#78791)
* apt - fix failure when package is not installed and only_upgrade=True (#78781) * apt - fix module failure when package is not installed and only_upgrade is True * changelog (cherry picked from commit 4b45b4b09d9257006f7b23237293c8c1a04521d8) * apt - fix module short-circuiting when a package is not installed and only_upgrade is True (cherry picked from commit 14f46845f9e74aac26aa54004c88a414926afc6a)
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/modules/apt.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ansible/modules/apt.py b/lib/ansible/modules/apt.py
index b254fb031e..08b3e14729 100644
--- a/lib/ansible/modules/apt.py
+++ b/lib/ansible/modules/apt.py
@@ -711,7 +711,12 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
package_names.append(name)
installed, installed_version, version_installable, has_files = package_status(m, name, version_cmp, version, default_release, cache, state='install')
- if (not installed_version and not version_installable) or (not installed and only_upgrade):
+ if not installed and only_upgrade:
+ # only_upgrade upgrades packages that are already installed
+ # since this package is not installed, skip it
+ continue
+
+ if not installed_version and not version_installable:
status = False
data = dict(msg="no available installation candidate for %s" % package)
return (status, data)