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
pull/78790/head
Sloane Hertel 2 years ago committed by GitHub
parent 9bc4fa496c
commit 4b45b4b09d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- apt - fix module failure when a package is not installed and only_upgrade=True (https://github.com/ansible/ansible/issues/78762).

@ -712,7 +712,7 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
installed, installed_version, version_installable, has_files = package_status(m, name, version_cmp, version, default_release, cache, state='install') 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_version and not version_installable) or (not installed and only_upgrade):
status = False status = not installed and only_upgrade
data = dict(msg="no available installation candidate for %s" % package) data = dict(msg="no available installation candidate for %s" % package)
return (status, data) return (status, data)

@ -54,7 +54,7 @@
# https://github.com/ansible/ansible/issues/30638 # https://github.com/ansible/ansible/issues/30638
- block: - block:
- name: Fail to install foo=1.0.1 since foo is not installed and only_upgrade is set - name: Do nothing to install foo=1.0.1 since foo is not installed and only_upgrade is set
apt: apt:
name: foo=1.0.1 name: foo=1.0.1
state: present state: present
@ -67,7 +67,7 @@
assert: assert:
that: that:
- "apt_result is not changed" - "apt_result is not changed"
- "apt_result is failed" - "apt_result is success"
- apt: - apt:
name: foo=1.0.0 name: foo=1.0.0

Loading…
Cancel
Save