From ea719649bb87e5ea1515f1a40af2e4748009571a Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 1 May 2024 21:30:02 +0200 Subject: [PATCH] apt_rpm: deprecate behavior of state=present and state=installed (#8285) * Deprecate behavior of state=present and state=installed. * Fix changelog fragment. Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- .../fragments/8285-apt_rpm-state-deprecate.yml | 7 +++++++ plugins/modules/apt_rpm.py | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 changelogs/fragments/8285-apt_rpm-state-deprecate.yml diff --git a/changelogs/fragments/8285-apt_rpm-state-deprecate.yml b/changelogs/fragments/8285-apt_rpm-state-deprecate.yml new file mode 100644 index 0000000000..19f3415841 --- /dev/null +++ b/changelogs/fragments/8285-apt_rpm-state-deprecate.yml @@ -0,0 +1,7 @@ +deprecated_features: + - "apt_rpm - the behavior of ``state=present`` and ``state=installed`` is deprecated and will change in community.general 11.0.0. + Right now the module will upgrade a package to the latest version if one of these two states is used. You should explicitly + use ``state=latest`` if you want this behavior, and switch to ``state=present_not_latest`` if you do not want to upgrade the + package if it is already installed. In community.general 11.0.0 the behavior of ``state=present`` and ``state=installed`` will + change to that of ``state=present_not_latest`` (https://github.com/ansible-collections/community.general/issues/8217, + https://github.com/ansible-collections/community.general/pull/8285)." diff --git a/plugins/modules/apt_rpm.py b/plugins/modules/apt_rpm.py index 07da307633..3a0b6d805f 100644 --- a/plugins/modules/apt_rpm.py +++ b/plugins/modules/apt_rpm.py @@ -310,6 +310,18 @@ def main(): module.fail_json(msg="cannot find /usr/bin/apt-get and/or /usr/bin/rpm") p = module.params + if p['state'] in ['installed', 'present']: + module.deprecate( + 'state=%s currently behaves unexpectedly by always upgrading to the latest version if' + ' the package is already installed. This behavior is deprecated and will change in' + ' community.general 11.0.0. You can use state=latest to explicitly request this behavior' + ' or state=present_not_latest to explicitly request the behavior that state=%s will have' + ' in community.general 11.0.0, namely that the package will not be upgraded if it is' + ' already installed.' % (p['state'], p['state']), + version='11.0.0', + collection_name='community.general', + ) + modified = False output = ""