Commit 6a15db32 authored by Stefan Schulte's avatar Stefan Schulte
Browse files

Handle the case where no key is installed

If there is currently no key present in the RPM keyring rpm -q returns
with a non-zero exitcode. This case is now handled properly so no
error message is shown when running puppet.
parent 320758b6
......@@ -4,7 +4,14 @@ Puppet::Type.type(:rpmkey).provide(:rpm) do
def self.instances
keys = []
rpm('-q','gpg-pubkey').each_line do |line|
rpm_query = rpm('-q','gpg-pubkey')
rescue Puppet::ExecutionFailure
return []
rpm_query.each_line do |line|
if match = /^gpg-pubkey-([0-9a-f]*)-[0-9a-f]*/.match(line)
keys << new(:name => match.captures[0].upcase, :ensure => :present)
......@@ -21,6 +21,11 @@ describe Puppet::Type.type(:rpmkey).provider(:rpm) do
it "should return an empty list if no key is installed" do
described_class.expects(:rpm).with('-q', 'gpg-pubkey').raises Puppet::ExecutionFailure, 'package gpg-pubkey is not installed'
described_class.instances.should be_empty
describe "#exists?" do
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment