diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2021-08-24 17:17:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-24 17:17:08 +0200 |
commit | 2ba9e35d09226f7c3664bf343f11043708a58997 (patch) | |
tree | cb528f478d5a98b900e069eabe6cafc42887011d | |
parent | Clarify get_bin_path error message (#75544) (diff) | |
download | ansible-2ba9e35d09226f7c3664bf343f11043708a58997.tar.xz ansible-2ba9e35d09226f7c3664bf343f11043708a58997.zip |
yum: fix yumstate when wildcards are used in list arg (#75545)
Fixes #74557
* map is not available on centos 6's jinja...
-rw-r--r-- | changelogs/fragments/74557-yum-list-wildcard.yml | 2 | ||||
-rw-r--r-- | lib/ansible/modules/yum.py | 2 | ||||
-rw-r--r-- | test/integration/targets/yum/tasks/repo.yml | 24 |
3 files changed, 28 insertions, 0 deletions
diff --git a/changelogs/fragments/74557-yum-list-wildcard.yml b/changelogs/fragments/74557-yum-list-wildcard.yml new file mode 100644 index 0000000000..536e67b3c4 --- /dev/null +++ b/changelogs/fragments/74557-yum-list-wildcard.yml @@ -0,0 +1,2 @@ +bugfixes: + - yum - fix ``yumstate`` return value when wildcards are used in the ``list`` argument (https://github.com/ansible/ansible/issues/74557) diff --git a/lib/ansible/modules/yum.py b/lib/ansible/modules/yum.py index 774cf95b69..6ece1d5160 100644 --- a/lib/ansible/modules/yum.py +++ b/lib/ansible/modules/yum.py @@ -599,6 +599,8 @@ class YumModule(YumDnf): rpmbin = self.module.get_bin_path('rpm', required=True) cmd = [rpmbin, '-q', '--qf', qf, pkgspec] + if '*' in pkgspec: + cmd.append('-a') if self.installroot != '/': cmd.extend(['--root', self.installroot]) # rpm localizes messages and we're screen scraping so make sure we use diff --git a/test/integration/targets/yum/tasks/repo.yml b/test/integration/targets/yum/tasks/repo.yml index c1a7a01654..f312b1ca3d 100644 --- a/test/integration/targets/yum/tasks/repo.yml +++ b/test/integration/targets/yum/tasks/repo.yml @@ -703,3 +703,27 @@ yum: name: dinginessentail,dinginessentail-olive,landsidescalping state: absent + +- block: + - yum: + name: dinginessentail + state: present + + - yum: + list: dinginessentail* + register: list_out + + - set_fact: + passed: true + loop: "{{ list_out.results }}" + when: item.yumstate == 'installed' + + - name: Test that there is yumstate=installed in the result + assert: + that: + - passed is defined + always: + - name: Clean up + yum: + name: dinginessentail + state: absent |