Skip to content

Commit e1f204b

Browse files
author
Ciprian Badescu
committed
(PUP-11024) enable dnfmodule with no default profile on newer dnf
When trying to install a module without default profile, newer `dnf` versions (eg. 4.2.23) show a different error message. This commit adapts the `dnf` error message expected in dnfmodule provider.
1 parent 9b390bc commit e1f204b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/puppet/provider/package/dnfmodule.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def install
9393
# module has no default profile and no profile was requested, so just enable the stream
9494
# DNF versions prior to 4.2.8 do not need this workaround
9595
# see https://bugzilla.redhat.com/show_bug.cgi?id=1669527
96-
if @resource[:flavor] == nil && e.message =~ /^missing groups or modules: #{Regexp.quote(@resource[:name])}$/
96+
if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(@resource[:name])}$/
9797
enable(args)
9898
else
9999
raise

spec/unit/provider/package/dnfmodule_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
provider.install
124124
end
125125

126-
it "should just enable the module if it has no default profile" do
126+
it "should just enable the module if it has no default profile(missing groups or modules)" do
127127
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}")
128128
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
129129
resource[:ensure] = :present
@@ -132,6 +132,15 @@
132132
provider.install
133133
end
134134

135+
it "should just enable the module if it has no default profile(broken groups or modules)" do
136+
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nbroken groups or modules: #{resource[:name]}")
137+
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
138+
resource[:ensure] = :present
139+
expect(provider).to receive(:execute).with(array_including('install')).ordered
140+
expect(provider).to receive(:execute).with(array_including('enable')).ordered
141+
provider.install
142+
end
143+
135144
it "should just enable the module if enable_only = true" do
136145
resource[:ensure] = :present
137146
resource[:enable_only] = true

0 commit comments

Comments
 (0)