Skip to content

Commit

Permalink
yum: fix 'package == version' syntax (ansible#47744)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrizek authored and Tomorrow9 committed Dec 4, 2018
1 parent ddc6727 commit 7605e02
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/47689-yum-fix-version-syntax.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- yum - fix "package == version" syntax (https://github.com/ansible/ansible/pull/47744)
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/yumdnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self, module):

# Fail if someone passed a space separated string
# https://github.com/ansible/ansible/issues/46301
if any((' ' in name and '@' not in name for name in self.names)):
if any((' ' in name and '@' not in name and '==' not in name for name in self.names)):
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 '
Expand Down
32 changes: 32 additions & 0 deletions test/integration/targets/yum/tasks/repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,35 @@
name: foo
state: absent
when: not (ansible_distribution == "Fedora" and ansible_distribution_major_version|int < 26)

# https://github.com/ansible/ansible/issues/47689
- block:
- name: Install foo == 1.0
yum:
name: "foo == 1.0"
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-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'

0 comments on commit 7605e02

Please sign in to comment.