diff --git a/manifests/source.pp b/manifests/source.pp index 2bd2e42..0512fa9 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -44,13 +44,14 @@ define apt::source( if $key != false { if $key_content { - exec { "Add key: ${key} from content": + exec { "Add key: ${key} from content for ${name}": command => "/bin/echo '${key_content}' | /usr/bin/apt-key add -", unless => "/usr/bin/apt-key list | /bin/grep '${key}'", before => File["${name}.list"], } } else { - exec { "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}": + exec { "Add key: ${key} from ${key_server} for ${name}": + command => "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}", unless => "/usr/bin/apt-key list | /bin/grep ${key}", before => File["${name}.list"], } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 01949b6..95c5a54 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -33,7 +33,7 @@ describe 'apt::source', :type => :define do ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do let :param_hash do - default_params.merge(param_set) + param_set == {} ? default_params : params end let :params do @@ -104,34 +104,37 @@ describe 'apt::source', :type => :define do it { if param_hash[:key] if param_hash[:key_content] - should contain_exec("Add key: #{param_hash[:key]} from content").with({ + should contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", "before" => "File[#{title}.list]" }) - should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}").with({ - "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", - "before" => "File[#{title}.list]" + should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ + "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", + "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", + "before" => "File[#{title}.list]" }) else - should contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}").with({ - "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", - "before" => "File[#{title}.list]" - }) - should_not contain_exec("Add key: #{param_hash[:key]} from content").with({ + should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", "before" => "File[#{title}.list]" - }) + }) + should contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ + "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", + "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", + "before" => "File[#{title}.list]" + }) end else - should_not contain_exec("Add key: #{param_hash[:key]} from content").with({ + should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", "before" => "File[#{title}.list]" }) - should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}").with({ + should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ + "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", "before" => "File[#{title}.list]" }) diff --git a/tests/source.pp b/tests/source.pp index 7d7321f..4db740d 100644 --- a/tests/source.pp +++ b/tests/source.pp @@ -9,3 +9,21 @@ apt::source { 'foo': key_server => 'keyserver.ubuntu.com', pin => '600' } + +# test two sources with the same key +apt::source { "debian_testing": + location => "http://debian.mirror.iweb.ca/debian/", + release => "testing", + repos => "main contrib non-free", + key => "55BE302B", + key_server => "subkeys.pgp.net", + pin => "-10" +} +apt::source { "debian_unstable": + location => "http://debian.mirror.iweb.ca/debian/", + release => "unstable", + repos => "main contrib non-free", + key => "55BE302B", + key_server => "subkeys.pgp.net", + pin => "-10" +}