diff options
author | Adam Miller <admiller@redhat.com> | 2018-11-05 15:00:42 -0600 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2018-11-05 15:15:43 -0800 |
commit | 3a14fe35e9233c94e69b6d3ef01e452a4464f479 (patch) | |
tree | 0df413064b07b3f987f5e25254e38f92f7df621e /lib/ansible/modules/packaging | |
parent | bab062d6391322828cfd7fd82a4310f5d567af2a (diff) | |
download | ansible-3a14fe35e9233c94e69b6d3ef01e452a4464f479.tar.gz |
Correct yum and dnf autoremove behavior (#47902)
* Correct yum and dnf autoremove behavior
Sanity check args passed to autoremove
Fixes #47184
Signed-off-by: Adam Miller <admiller@redhat.com>
* fix docs
Signed-off-by: Adam Miller <admiller@redhat.com>
(cherry picked from commit 1c777976c5134f310a97609da12776fc08551271)
Diffstat (limited to 'lib/ansible/modules/packaging')
-rw-r--r-- | lib/ansible/modules/packaging/os/dnf.py | 8 | ||||
-rw-r--r-- | lib/ansible/modules/packaging/os/yum.py | 3 |
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/ansible/modules/packaging/os/dnf.py b/lib/ansible/modules/packaging/os/dnf.py index fee5f5d2c6..5a15eeb73c 100644 --- a/lib/ansible/modules/packaging/os/dnf.py +++ b/lib/ansible/modules/packaging/os/dnf.py @@ -41,8 +41,9 @@ options: state: description: - Whether to install (C(present), C(latest)), or remove (C(absent)) a package. + - Default is C(None), however in effect the default action is C(present) unless the C(autoremove) option is + enabled for this module, then C(absent) is inferred. choices: ['absent', 'present', 'installed', 'removed', 'latest'] - default: "present" enablerepo: description: @@ -1017,11 +1018,6 @@ class DnfModule(YumDnf): msg="Autoremove requires dnf>=2.0.1. Current dnf version is %s" % dnf.__version__, results=[], ) - if self.state not in ["absent", None]: - self.module.fail_json( - msg="Autoremove should be used alone or with state=absent", - results=[], - ) # Set state as installed by default # This is not set in AnsibleModule() because the following shouldn't happend diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index f6b93d5ea1..a5780742f7 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -56,8 +56,9 @@ options: - C(present) and C(installed) will simply ensure that a desired package is installed. - C(latest) will update the specified package if it's not of the latest available version. - C(absent) and C(removed) will remove the specified package. + - Default is C(None), however in effect the default action is C(present) unless the C(autoremove) option isĀ¬ + enabled for this module, then C(absent) is inferred. choices: [ absent, installed, latest, present, removed ] - default: present enablerepo: description: - I(Repoid) of repositories to enable for the install/update operation. |