From 0176c8893b0cbb8d6340ad000a5abb01c5e4e7f0 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Tue, 21 May 2019 17:37:05 +0200 Subject: [PATCH] yum: fix false error msg about autoremove support (#56459) * yum: fix false error msg about autoremove support (cherry picked from commit a68ac729ea3a090553f9bec40992135337c4146b) --- .../fragments/56458-yum-fix-false-error-msg-autoremove.yaml | 2 ++ lib/ansible/modules/packaging/os/yum.py | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/56458-yum-fix-false-error-msg-autoremove.yaml diff --git a/changelogs/fragments/56458-yum-fix-false-error-msg-autoremove.yaml b/changelogs/fragments/56458-yum-fix-false-error-msg-autoremove.yaml new file mode 100644 index 00000000000..7d6f549b549 --- /dev/null +++ b/changelogs/fragments/56458-yum-fix-false-error-msg-autoremove.yaml @@ -0,0 +1,2 @@ +bugfixes: + - yum - Fix false error message about autoremove not being supported (https://github.com/ansible/ansible/issues/56458) diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index 8e706a21b64..8aa1db66d3b 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -1067,9 +1067,8 @@ class YumModule(YumDnf): res['msg'] = err if rc != 0: - if self.autoremove: - if 'No such command' not in out: - self.module.fail_json(msg='Version of YUM too old for autoremove: Requires yum 3.4.3 (RHEL/CentOS 7+)') + if self.autoremove and 'No such command' in out: + self.module.fail_json(msg='Version of YUM too old for autoremove: Requires yum 3.4.3 (RHEL/CentOS 7+)') else: self.module.fail_json(**res)