diff --git a/lib/puppet/provider/package/dnfmodule.rb b/lib/puppet/provider/package/dnfmodule.rb index d6cf9f6d143..710fd806bbb 100644 --- a/lib/puppet/provider/package/dnfmodule.rb +++ b/lib/puppet/provider/package/dnfmodule.rb @@ -93,7 +93,7 @@ def install # module has no default profile and no profile was requested, so just enable the stream # DNF versions prior to 4.2.8 do not need this workaround # see https://bugzilla.redhat.com/show_bug.cgi?id=1669527 - if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(@resource[:name])}$/ + if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(args)}$/ enable(args) else raise diff --git a/spec/unit/provider/package/dnfmodule_spec.rb b/spec/unit/provider/package/dnfmodule_spec.rb index cdb90e7550a..4cb00136d5c 100644 --- a/spec/unit/provider/package/dnfmodule_spec.rb +++ b/spec/unit/provider/package/dnfmodule_spec.rb @@ -123,7 +123,7 @@ provider.install end - it "should just enable the module if it has no default profile(missing groups or modules)" do + it "should just enable the module if it has no default profile (missing groups or modules)" do dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}") allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception) resource[:ensure] = :present @@ -132,7 +132,17 @@ provider.install end - it "should just enable the module if it has no default profile(broken groups or modules)" do + it "should just enable the module with the right stream if it has no default profile (missing groups or modules)" do + stream = '12.3' + dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}:#{stream}") + allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception) + resource[:ensure] = stream + expect(provider).to receive(:execute).with(array_including('install')).ordered + expect(provider).to receive(:execute).with(array_including('enable')).ordered + provider.install + end + + it "should just enable the module if it has no default profile (broken groups or modules)" do dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nbroken groups or modules: #{resource[:name]}") allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception) resource[:ensure] = :present @@ -141,6 +151,16 @@ provider.install end + it "should just enable the module with the right stream if it has no default profile (broken groups or modules)" do + stream = '12.3' + dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nbroken groups or modules: #{resource[:name]}:#{stream}") + allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception) + resource[:ensure] = stream + expect(provider).to receive(:execute).with(array_including('install')).ordered + expect(provider).to receive(:execute).with(array_including('enable')).ordered + provider.install + end + it "should just enable the module if enable_only = true" do resource[:ensure] = :present resource[:enable_only] = true