# Key: 55BE302B Server: subkeys.pgp.net
# debian-keyring
# debian-archive-keyring
-
+
apt::source { "debian_unstable":
location => "http://debian.mirror.iweb.ca/debian/",
release => "unstable",
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}":
unless => "/usr/bin/apt-key list | /bin/grep ${key}",
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
let :param_hash do
- param_set == {} ? default_params : params
+ default_params.merge(param_set)
end
let :params do
it { should contain_package("python-software-properties") }
it {
- should create_file("sources.list")\
- .with_path("/etc/apt/sources.list")\
- .with_ensure("present")\
- .with_owner("root")\
- .with_group("root")\
- .with_mode(644)
+ should contain_file("sources.list").with({
+ 'path' => "/etc/apt/sources.list",
+ 'ensure' => "present",
+ 'owner' => "root",
+ 'group' => "root",
+ 'mode' => 644
+ })
}
it {
- should create_file("sources.list.d")\
- .with_path("/etc/apt/sources.list.d")\
- .with_ensure("directory")\
- .with_owner("root")\
- .with_group("root")
+ should create_file("sources.list.d").with({
+ "path" => "/etc/apt/sources.list.d",
+ "ensure" => "directory",
+ "owner" => "root",
+ "group" => "root"
+ })
}
it {
- should create_exec("apt_update")\
- .with_command("/usr/bin/apt-get update")\
- .with_subscribe(["File[sources.list]", "File[sources.list.d]"])\
- .with_refreshonly(refresh_only_apt_update)
+ should contain_exec("apt_update").with({
+ 'command' => "/usr/bin/apt-get update",
+ 'subscribe' => ["File[sources.list]", "File[sources.list.d]"],
+ 'refreshonly' => refresh_only_apt_update
+ })
}
it {
if param_hash[:disable_keys]
- should create_exec("make-apt-insecure")\
- .with_command('/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth')\
- .with_creates('/etc/apt/apt.conf.d/99unauth')
+ should contain_exec("make-apt-insecure").with({
+ 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth',
+ 'creates' => '/etc/apt/apt.conf.d/99unauth'
+ })
else
- should_not create_exec("make-apt-insecure")\
- .with_command('/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth')\
- .with_creates('/etc/apt/apt.conf.d/99unauth')
+ should_not contain_exec("make-apt-insecure").with({
+ 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth',
+ 'creates' => '/etc/apt/apt.conf.d/99unauth'
+ })
end
}
end
require 'spec_helper'
describe 'apt::debian::testing', :type => :class do
it {
- should create_resource("Apt::source", "debian_testing")\
- .with_param("location", "http://debian.mirror.iweb.ca/debian/")\
- .with_param("release", "testing")\
- .with_param("repos", "main contrib non-free")\
- .with_param("required_packages", "debian-keyring debian-archive-keyring")\
- .with_param("key", "55BE302B")\
- .with_param("key_server", "subkeys.pgp.net")\
- .with_param("pin", "-10")
+ should contain_apt__source("debian_testing").with({
+ "location" => "http://debian.mirror.iweb.ca/debian/",
+ "release" => "testing",
+ "repos" => "main contrib non-free",
+ "required_packages" => "debian-keyring debian-archive-keyring",
+ "key" => "55BE302B",
+ "key_server" => "subkeys.pgp.net",
+ "pin" => "-10"
+ })
}
end
require 'spec_helper'
describe 'apt::debian::unstable', :type => :class do
it {
- should create_resource("Apt::source", "debian_unstable")\
- .with_param("location", "http://debian.mirror.iweb.ca/debian/")\
- .with_param("release", "unstable")\
- .with_param("repos", "main contrib non-free")\
- .with_param("required_packages", "debian-keyring debian-archive-keyring")\
- .with_param("key", "55BE302B")\
- .with_param("key_server", "subkeys.pgp.net")\
- .with_param("pin", "-10")
+ should contain_apt__source("debian_unstable").with({
+ "location" => "http://debian.mirror.iweb.ca/debian/",
+ "release" => "unstable",
+ "repos" => "main contrib non-free",
+ "required_packages" => "debian-keyring debian-archive-keyring",
+ "key" => "55BE302B",
+ "key_server" => "subkeys.pgp.net",
+ "pin" => "-10"
+ })
}
end
describe 'apt::params', :type => :class do
let (:title) { 'my_package' }
- it { should create_class("apt::params") }
+ it { should contain_apt__params }
# There are 4 resources in this class currently
# there should not be any more resources because it is a params class
it { should include_class("apt::params") }
it {
- should contain_file("/etc/apt/apt.conf.d/01release")\
- .with_owner("root")\
- .with_group("root")\
- .with_mode(644)\
- .with_content("APT::Default-Release \"#{param_set[:release_id]}\";")
+ should contain_file("/etc/apt/apt.conf.d/01release").with({
+ "owner" => "root",
+ "group" => "root",
+ "mode" => 644,
+ "content" => "APT::Default-Release \"#{param_set[:release_id]}\";"
+ })
}
end
describe "should succeed with a Class['apt']" do
let(:pre_condition) { 'class {"apt": } ' }
- it { should contain_exec("apt-update-#{title}").with_command("/usr/bin/apt-get update").with_refreshonly(true) }
+ it { should contain_exec("apt-update-#{title}").with({
+ 'command' => "/usr/bin/apt-get update",
+ 'refreshonly' => true
+ })
+ }
end
describe "should fail without Class['apt']" do
- it { expect {should contain_exec("apt-update-#{title}").with_command("/usr/bin/apt-get update").with_refreshonly(true) }\
- .to raise_error(Puppet::Error)
+ it { expect {should contain_exec("apt-update-#{title}").with({
+ 'command' => "/usr/bin/apt-get update",
+ 'refreshonly' => true
+ }).to raise_error(Puppet::Error)
+ }
}
end
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
let :param_hash do
- param_set == {} ? default_params : params
+ default_params.merge(param_set)
end
let :params do
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
let :param_hash do
- param_set == {} ? default_params : params
+ default_params.merge(param_set)
end
let :params do
it { should include_class("apt::params") }
- it { should create_file("#{title}.pref")\
- .with_path("/etc/apt/preferences.d/#{title}")\
- .with_ensure("file")\
- .with_owner("root")\
- .with_group("root")\
- .with_mode("644")\
- .with_content("# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}")
+ it { should contain_file("#{title}.pref").with({
+ 'path' => "/etc/apt/preferences.d/#{title}",
+ 'ensure' => "file",
+ 'owner' => "root",
+ 'group' => "root",
+ 'mode' => "644",
+ 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}"
+ })
}
end
end
'notify' => "Exec[apt-update-#{t}]"
)
}
- it { should contain_exec("add-apt-repository-#{t}").with_unless(unless_statement) }
+ it { should contain_exec("add-apt-repository-#{t}").with({"unless" => unless_statement}) }
it { should contain_exec("apt-update-#{t}").with(
'command' => '/usr/bin/aptitude update',
'refreshonly' => true
describe "without Class[apt] should raise a Puppet::Error" do
let(:title) { "ppa" }
- it { expect { should create_resource("apt::ppa", title) }.to raise_error(Puppet::Error) }
+ it { expect { should contain_apt__ppa(title) }.to raise_error(Puppet::Error) }
end
end
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
let :param_hash do
- param_set == {} ? default_params : params
+ default_params.merge(param_set)
end
let :params do
content
end
- it { should contain_class("apt::params") }
+ it { should contain_apt__params }
- it { should contain_file("#{title}.list")\
- .with_path(filename)\
- .with_ensure("file")\
- .with_owner("root")\
- .with_group("root")\
- .with_mode(644)\
- .with_content(content)
+ it { should contain_file("#{title}.list").with({
+ 'path' => filename,
+ 'ensure' => "file",
+ 'owner' => "root",
+ 'group' => "root",
+ 'mode' => 644,
+ 'content' => content
+ })
}
it {
if param_hash[:pin]
- should create_resource("apt::pin", param_hash[:release]).with_param("priority", param_hash[:pin]).with_param("before", "File[#{title}.list]")
+ should contain_apt__pin(param_hash[:release]).with({
+ "priority" => param_hash[:pin],
+ "before" => "File[#{title}.list]"
+ })
else
- should_not create_resource("apt::pin", param_hash[:release]).with_param("priority", param_hash[:pin]).with_param("before", "File[#{title}.list]")
+ should_not contain_apt__pin(param_hash[:release]).with({
+ "priority" => param_hash[:pin],
+ "before" => "File[#{title}.list]"
+ })
end
}
it {
- should contain_exec("#{title} apt update")\
- .with_command("/usr/bin/apt-get update")\
- .with_subscribe("File[#{title}.list]")\
- .with_refreshonly(true)
+ should contain_exec("#{title} apt update").with({
+ "command" => "/usr/bin/apt-get update",
+ "subscribe" => "File[#{title}.list]",
+ "refreshonly" => true
+ })
}
it {
if param_hash[:required_packages]
- should contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}")\
- .with_subscribe("File[#{title}.list]")\
- .with_refreshonly(true)
+ should contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}").with({
+ "subscribe" => "File[#{title}.list]",
+ "refreshonly" => true
+ })
else
- should_not contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}")\
- .with_subscribe("File[#{title}.list]")\
- .with_refreshonly(true)
+ should_not contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}").with({
+ "subscribe" => "File[#{title}.list]",
+ "refreshonly" => true
+ })
end
}
it {
if param_hash[:key]
if param_hash[:key_content]
- should contain_exec("Add key: #{param_hash[:key]} from content")\
- .with_command("/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -")\
- .with_unless("/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'")\
- .with_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]}")\
- .with_before("File[#{title}.list]")
+ should contain_exec("Add key: #{param_hash[:key]} from content").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]"
+ })
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]}")\
- .with_before("File[#{title}.list]")
- should_not contain_exec("Add key: #{param_hash[:key]} from content")\
- .with_command("/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -")\
- .with_unless("/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'")\
- .with_before("File[#{title}.list]")
+ 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({
+ "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]"
+ })
end
else
- should_not contain_exec("Add key: #{param_hash[:key]} from content")\
- .with_command("/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -")\
- .with_unless("/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'")\
- .with_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]}")\
- .with_before("File[#{title}.list]")
+ should_not contain_exec("Add key: #{param_hash[:key]} from content").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]"
+ })
end
}