Skip to content

Commit 6715a68

Browse files
SvenVD-beSven Van Dyck
authored andcommitted
Add assumeyes to yum check-update
This solves the observed on at least RHEL8 if repo_gpgcheck=1 AND baseurl is changed (by a yumrepo resources for example) AND no other puppet package with dnf -y (assumeyes) has been run then dnf asks to re-import already imported keys (the key needs to be imported into dnf's databases, which is separate from rpm database and it is a new database per baseurl https://bugzilla.redhat.com/show_bug.cgi?id=1768206) If puppet then runs dnf check-update because of a package has ensure => latest then it fails with: Warning: Puppet::Type::Package::ProviderDnf: Could not check for updates, '/bin/dnf check-update' exited with 1 Add assumeyes to check-update, this also makes it more consistent with the other dnf commands in yum.rb which also use "-y"
1 parent 1c17eb4 commit 6715a68

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/puppet/provider/package/yum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def self.latest_package_version(package, disablerepo, enablerepo, disableexclude
111111
# @return [Hash<String, Array<Hash<String, String>>>] All packages that were
112112
# found with a list of found versions for each package.
113113
def self.check_updates(disablerepo, enablerepo, disableexcludes)
114-
args = [command(:cmd), 'check-update']
114+
args = [command(:cmd), '-y', 'check-update']
115115
args.concat(disablerepo.map { |repo| ["--disablerepo=#{repo}"] }.flatten)
116116
args.concat(enablerepo.map { |repo| ["--enablerepo=#{repo}"] }.flatten)
117117
args.concat(disableexcludes.map { |repo| ["--disableexcludes=#{repo}"] }.flatten)

spec/shared_examples/rhel_package_provider.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,39 +327,39 @@
327327
describe "executing #{provider_name} check-update" do
328328
it "passes repos to enable to '#{provider_name} check-update'" do
329329
expect(Puppet::Util::Execution).to receive(:execute).with(
330-
%W[/usr/bin/#{provider_name} check-update --enablerepo=updates --enablerepo=centosplus],
330+
%W[/usr/bin/#{provider_name} -y check-update --enablerepo=updates --enablerepo=centosplus],
331331
any_args
332332
).and_return(double(:exitstatus => 0))
333333
described_class.check_updates([], %W[updates centosplus], [])
334334
end
335335

336336
it "passes repos to disable to '#{provider_name} check-update'" do
337337
expect(Puppet::Util::Execution).to receive(:execute).with(
338-
%W[/usr/bin/#{provider_name} check-update --disablerepo=updates --disablerepo=centosplus],
338+
%W[/usr/bin/#{provider_name} -y check-update --disablerepo=updates --disablerepo=centosplus],
339339
any_args
340340
).and_return(double(:exitstatus => 0))
341341
described_class.check_updates(%W[updates centosplus], [], [])
342342
end
343343

344344
it "passes a combination of repos to enable and disable to '#{provider_name} check-update'" do
345345
expect(Puppet::Util::Execution).to receive(:execute).with(
346-
%W[/usr/bin/#{provider_name} check-update --disablerepo=updates --disablerepo=centosplus --enablerepo=os --enablerepo=contrib ],
346+
%W[/usr/bin/#{provider_name} -y check-update --disablerepo=updates --disablerepo=centosplus --enablerepo=os --enablerepo=contrib ],
347347
any_args
348348
).and_return(double(:exitstatus => 0))
349349
described_class.check_updates(%W[updates centosplus], %W[os contrib], [])
350350
end
351351

352352
it "passes disableexcludes to '#{provider_name} check-update'" do
353353
expect(Puppet::Util::Execution).to receive(:execute).with(
354-
%W[/usr/bin/#{provider_name} check-update --disableexcludes=main --disableexcludes=centosplus],
354+
%W[/usr/bin/#{provider_name} -y check-update --disableexcludes=main --disableexcludes=centosplus],
355355
any_args
356356
).and_return(double(:exitstatus => 0))
357357
described_class.check_updates([], [], %W[main centosplus])
358358
end
359359

360360
it "passes all options to '#{provider_name} check-update'" do
361361
expect(Puppet::Util::Execution).to receive(:execute).with(
362-
%W[/usr/bin/#{provider_name} check-update --disablerepo=a --disablerepo=b --enablerepo=c --enablerepo=d --disableexcludes=e --disableexcludes=f],
362+
%W[/usr/bin/#{provider_name} -y check-update --disablerepo=a --disablerepo=b --enablerepo=c --enablerepo=d --disableexcludes=e --disableexcludes=f],
363363
any_args
364364
).and_return(double(:exitstatus => 0))
365365
described_class.check_updates(%W[a b], %W[c d], %W[e f])

0 commit comments

Comments
 (0)