diff --git a/lib/ansible/modules/yum.py b/lib/ansible/modules/yum.py index 68d4ff1e8e3..8d4cc4a522b 100644 --- a/lib/ansible/modules/yum.py +++ b/lib/ansible/modules/yum.py @@ -1159,7 +1159,7 @@ class YumModule(YumDnf): if pkg.startswith('@'): installed = self.is_group_env_installed(pkg) else: - installed = self.is_installed(repoq, pkg) + installed = self.is_installed(repoq, pkg, is_pkg=True) if installed: # Return a message so it's obvious to the user why yum failed diff --git a/test/integration/targets/yum/tasks/yum.yml b/test/integration/targets/yum/tasks/yum.yml index a8f29cad665..e4cfbc65e1f 100644 --- a/test/integration/targets/yum/tasks/yum.yml +++ b/test/integration/targets/yum/tasks/yum.yml @@ -838,3 +838,31 @@ # actually honored and those releases are EOL'd so we have no expectation they # will ever be fixed when: not ((ansible_distribution == "Fedora") and (ansible_distribution_major_version|int < 26)) + +- name: Check that packages with Provides are handled correctly in state=absent + block: + - name: Install test packages + yum: + name: + - https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/yum/test-package-that-provides-toaster-1.3.3.7-1.el7.noarch.rpm + - https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/yum/toaster-1.2.3.4-1.el7.noarch.rpm + register: install + + - name: Remove toaster + yum: + name: toaster + state: absent + register: remove + + - name: rpm -qa + command: rpm -qa + register: rpmqa + + - assert: + that: + - install is successful + - install is changed + - remove is successful + - remove is changed + - "'toaster-1.2.3.4' not in rpmqa.stdout" + - "'test-package-that-provides-toaster' in rpmqa.stdout"