DNF Handle Empty AppStream stream definition (#63819)

* DNF Handle Empty AppStream stream definition

Fixes #63683

Signed-off-by: Adam Miller <admiller@redhat.com>

* 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 <admiller@redhat.com>
This commit is contained in:
Adam Miller 2019-10-24 00:57:31 -04:00 committed by ansibot
parent b96ae6ab67
commit ed86907587
5 changed files with 63 additions and 3 deletions

View file

@ -0,0 +1,3 @@
---
minor_changes:
- dnf - Properly handle module AppStreams that don't define stream (https://github.com/ansible/ansible/issues/63683)

View file

@ -886,9 +886,16 @@ class DnfModule(YumDnf):
if self.with_modules: if self.with_modules:
module_spec = module_spec.strip() module_spec = module_spec.strip()
module_list, nsv = self.module_base._get_modules(module_spec) 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): if enabled_streams:
return True 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 return False # seems like a sane default

View file

@ -49,3 +49,51 @@
that: that:
- "not dnf_result.failed" - "not dnf_result.failed"
- "not dnf_result.changed" - "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"

View file

@ -1 +1,2 @@
astream_name: '@ripgrep:master/default' astream_name: '@stratis:1/default'
astream_name_no_stream: '@stratis/default'

View file

@ -1 +1,2 @@
astream_name: '@php:7.2/minimal' astream_name: '@php:7.2/minimal'
astream_name_no_stream: '@php/minimal'