Allow all of yum version compare operators (#54603)
* Allow all of yum version compare operators * * yum: name="foo >= VERSION" integration test * changelog fragment
This commit is contained in:
parent
221da3e8b1
commit
1532e31ec0
3 changed files with 60 additions and 6 deletions
3
changelogs/fragments/yum-select-version.yml
Normal file
3
changelogs/fragments/yum-select-version.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- "yum allows comparison operators like '>=' for selecting package version"
|
|
@ -101,7 +101,8 @@ class YumDnf(with_metaclass(ABCMeta, object)):
|
|||
|
||||
# Fail if someone passed a space separated string
|
||||
# https://github.com/ansible/ansible/issues/46301
|
||||
if any((' ' in name and '@' not in name and '==' not in name for name in self.names)):
|
||||
for name in self.names:
|
||||
if ' ' in name and not any(spec in name for spec in ['@', '>', '<', '=']):
|
||||
module.fail_json(
|
||||
msg='It appears that a space separated string of packages was passed in '
|
||||
'as an argument. To operate on several packages, pass a comma separated '
|
||||
|
|
|
@ -589,6 +589,56 @@
|
|||
|
||||
when: ansible_pkg_mgr == 'yum'
|
||||
|
||||
|
||||
# https://github.com/ansible/ansible/pull/54603
|
||||
- block:
|
||||
- name: Install foo < 1.1
|
||||
yum:
|
||||
name: "foo < 1.1"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check foo with rpm
|
||||
shell: rpm -q foo
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('foo-1.0')"
|
||||
|
||||
- name: Install foo >= 1.1
|
||||
yum:
|
||||
name: "foo >= 1.1"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: Check foo with rpm
|
||||
shell: rpm -q foo
|
||||
register: rpm_result
|
||||
|
||||
- name: Verify installation
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.changed"
|
||||
- "rpm_result.stdout.startswith('foo-1.1')"
|
||||
|
||||
- name: Verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
always:
|
||||
- name: Clean up
|
||||
yum:
|
||||
name: foo
|
||||
state: absent
|
||||
|
||||
when: ansible_pkg_mgr == 'yum'
|
||||
|
||||
# https://github.com/ansible/ansible/issues/45250
|
||||
- block:
|
||||
- name: Install foo-1.0, foo-bar-1.0, bar-1.0
|
||||
|
|
Loading…
Reference in a new issue