Skip to content

Commit

Permalink
DNF Handle Empty AppStream stream definition (ansible#63819)
Browse files Browse the repository at this point in the history
* DNF Handle Empty AppStream stream definition

Fixes ansible#63683

Signed-off-by: Adam Miller <[email protected]>

* Switch Fedora dnf test target modularity to stratis

In Fedora 29, the metadata was not properly set for a default stream
for ripgrep even though there is a profile called "default", however
that's an arbitrary string and the module maintainer must set the
default stream (which it never was for the ripgrep module, thus
failing the "empty stream" install test)

Signed-off-by: Adam Miller <[email protected]>
  • Loading branch information
maxamillion authored and ansibot committed Oct 24, 2019
1 parent b96ae6a commit ed86907
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- dnf - Properly handle module AppStreams that don't define stream (https://github.com/ansible/ansible/issues/63683)
11 changes: 9 additions & 2 deletions lib/ansible/modules/packaging/os/dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,9 +886,16 @@ def _is_module_installed(self, module_spec):
if self.with_modules:
module_spec = module_spec.strip()
module_list, nsv = self.module_base._get_modules(module_spec)
enabled_streams = self.base._moduleContainer.getEnabledStream(nsv.name)

if nsv.stream in self.base._moduleContainer.getEnabledStream(nsv.name):
return True
if enabled_streams:
if nsv.stream:
if nsv.stream in enabled_streams:
return True # The provided stream was found
else:
return False # The provided stream was not found
else:
return True # No stream provided, but module found

return False # seems like a sane default

Expand Down
48 changes: 48 additions & 0 deletions test/integration/targets/dnf/tasks/modularity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,51 @@
that:
- "not dnf_result.failed"
- "not dnf_result.changed"

- name: install "{{ astream_name_no_stream }}" module without providing stream
dnf:
name: "{{ astream_name_no_stream }}"
state: present
register: dnf_result

- name: verify installation of "{{ astream_name_no_stream }}" module without providing stream
assert:
that:
- "not dnf_result.failed"
- "dnf_result.changed"

- name: install "{{ astream_name_no_stream }}" module again without providing stream
dnf:
name: "{{ astream_name_no_stream }}"
state: present
register: dnf_result

- name: verify installation of "{{ astream_name_no_stream }}" module again without providing stream
assert:
that:
- "not dnf_result.failed"
- "not dnf_result.changed"

- name: uninstall "{{ astream_name_no_stream }}" module without providing stream
dnf:
name: "{{ astream_name_no_stream }}"
state: absent
register: dnf_result

- name: verify uninstallation of "{{ astream_name_no_stream }}" module without providing stream
assert:
that:
- "not dnf_result.failed"
- "dnf_result.changed"

- name: uninstall "{{ astream_name_no_stream }}" module again without providing stream
dnf:
name: "{{ astream_name_no_stream }}"
state: absent
register: dnf_result

- name: verify uninstallation of "{{ astream_name_no_stream }}" module again without providing stream
assert:
that:
- "not dnf_result.failed"
- "not dnf_result.changed"
3 changes: 2 additions & 1 deletion test/integration/targets/dnf/vars/Fedora.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
astream_name: '@ripgrep:master/default'
astream_name: '@stratis:1/default'
astream_name_no_stream: '@stratis/default'
1 change: 1 addition & 0 deletions test/integration/targets/dnf/vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
astream_name: '@php:7.2/minimal'
astream_name_no_stream: '@php/minimal'

0 comments on commit ed86907

Please sign in to comment.