From 1492f46d789262180a6b2e00dc3223c354171f59 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Tue, 5 Feb 2019 18:18:56 +0100 Subject: [PATCH] yum: disableexcludes is supported on centos6 (#51698) (cherry picked from commit 33b07f322cddd229642e73541d7ecb0bf28ccfc4) --- ...-errors-with-disable-includes-message.yaml | 2 + lib/ansible/modules/packaging/os/yum.py | 3 - test/integration/targets/yum/tasks/yum.yml | 58 +------------------ 3 files changed, 3 insertions(+), 60 deletions(-) create mode 100644 changelogs/fragments/51697-disable_excludes-errors-with-disable-includes-message.yaml diff --git a/changelogs/fragments/51697-disable_excludes-errors-with-disable-includes-message.yaml b/changelogs/fragments/51697-disable_excludes-errors-with-disable-includes-message.yaml new file mode 100644 index 00000000000..9dd9359b04f --- /dev/null +++ b/changelogs/fragments/51697-disable_excludes-errors-with-disable-includes-message.yaml @@ -0,0 +1,2 @@ +bugfixes: + - yum - Remove incorrect disable_includes error message when using disable_excludes (https://github.com/ansible/ansible/issues/51697) diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index 4231542124d..ae94308a351 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -1486,9 +1486,6 @@ class YumModule(YumDnf): if not HAS_YUM_PYTHON: error_msgs.append('The Python 2 yum module is needed for this module. If you require Python 3 support use the `dnf` Ansible module instead.') - if self.disable_excludes and yum.__version_info__ < (3, 4): - self.module.fail_json(msg="'disable_includes' is available in yum version 3.4 and onwards.") - if error_msgs: self.module.fail_json(msg='. '.join(error_msgs)) diff --git a/test/integration/targets/yum/tasks/yum.yml b/test/integration/targets/yum/tasks/yum.yml index 1e99af9b19b..7957e8bb167 100644 --- a/test/integration/targets/yum/tasks/yum.yml +++ b/test/integration/targets/yum/tasks/yum.yml @@ -631,16 +631,6 @@ with_items: "{{ yum_version.results }}" - block: - - name: check whether yum supports disableexcludes (>= 3.4) - set_fact: - supports_disable_excludes: "{{ yum_version is version_compare('3.4.0', '>=') }}" - when: ansible_pkg_mgr == "yum" - - - name: unset disableexcludes tests for dnf(yum4) backend temporarily - set_fact: - supports_disable_excludes: True - when: ansible_pkg_mgr == "dnf" - - name: uninstall bc yum: name=bc state=removed @@ -675,18 +665,15 @@ yum: name=bc state=latest register: yum_bc_result ignore_errors: True - when: supports_disable_excludes - name: verify bc did not install because it is in exclude list assert: that: - "yum_bc_result is failed" - when: supports_disable_excludes - name: install bc with disable_excludes yum: name=bc state=latest disable_excludes=all register: yum_bc_result_using_excludes - when: supports_disable_excludes - name: verify bc did install using disable_excludes=all assert: @@ -694,7 +681,6 @@ - "yum_bc_result_using_excludes is success" - "yum_bc_result_using_excludes is changed" - "yum_bc_result_using_excludes is not failed" - when: supports_disable_excludes - name: remove exclude bc (cleanup yum.conf) lineinfile: @@ -702,7 +688,7 @@ regexp: (^exclude=bc*) line: "exclude=" state: present - when: supports_disable_excludes and (ansible_pkg_mgr == 'yum') + when: ansible_pkg_mgr == 'yum' - name: remove exclude bc (cleanup dnf.conf) lineinfile: @@ -711,48 +697,6 @@ line: "excludepkgs=" state: present when: ansible_pkg_mgr == 'dnf' - # end test case where disable_excludes is supported - - # begin test case where disable_excludes is not supported - - name: Try install bc with disable_excludes - yum: name=bc state=latest disable_excludes=all - register: yum_fail_bc_result_old_yum - ignore_errors: True - when: not supports_disable_excludes - - - name: verify packages did not install because yum version is unsupported - assert: - that: - - "yum_fail_bc_result_old_yum is failed" - when: not supports_disable_excludes - - - name: verify yum module outputs - assert: - that: - - "'is available in yum version 3.4 and onwards.' in yum_fail_bc_result_old_yum.msg" - when: not supports_disable_excludes - - - name: remove exclude bc (cleanup yum.conf) - lineinfile: - dest: /etc/yum.conf - regexp: (^exclude=bc*) - line: "exclude=" - state: present - when: not supports_disable_excludes and ansible_pkg_mgr == 'yum' - - - name: install bc (bring test env in same state as when testing started) - yum: name=bc state=latest - register: yum_bc_result_old_yum - when: not supports_disable_excludes - - - name: verify bc installed - assert: - that: - - "yum_bc_result_old_yum is success" - - "yum_bc_result_old_yum is changed" - - "yum_bc_result_old_yum is not failed" - when: not supports_disable_excludes and ansible_pkg_mgr == "yum" - # end test case where disable_excludes is not supported # Fedora < 26 has a bug in dnf where package excludes in dnf.conf aren't # actually honored and those releases are EOL'd so we have no expectation they