2 describe 'apt::source', :type => :define do
13 :required_packages => false,
15 :key_server => 'keyserver.ubuntu.com',
23 :location => 'somewhere',
24 :release => 'precise',
26 :include_src => false,
27 :required_packages => 'apache',
29 :key_server => 'keyserver.debian.com',
31 :key_content => 'ABCD1234'
35 :key_server => 'keyserver.debian.com',
36 :key_content => false,
39 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
41 default_params.merge(param_set)
49 "/etc/apt/sources.list.d/#{title}.list"
53 content = "# #{title}"
54 content << "\ndeb #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
55 if param_hash[:include_src]
56 content << "deb-src #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
61 it { should contain_apt__params }
63 it { should contain_file("#{title}.list").with({
75 should contain_apt__pin(param_hash[:release]).with({
76 "priority" => param_hash[:pin],
77 "before" => "File[#{title}.list]"
80 should_not contain_apt__pin(param_hash[:release]).with({
81 "priority" => param_hash[:pin],
82 "before" => "File[#{title}.list]"
88 should contain_exec("#{title} apt update").with({
89 "command" => "/usr/bin/apt-get update",
90 "subscribe" => "File[#{title}.list]",
96 if param_hash[:required_packages]
97 should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
98 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
99 "subscribe" => "File[#{title}.list]",
100 "refreshonly" => true
103 should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
104 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
105 "subscribe" => "File[#{title}.list]",
106 "refreshonly" => true
113 if param_hash[:key_content]
114 should contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({
115 "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -",
116 "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'",
117 "before" => "File[#{title}.list]"
120 should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({
121 "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -",
122 "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'",
123 "before" => "File[#{title}.list]"
127 should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({
128 "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -",
129 "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'",
130 "before" => "File[#{title}.list]"
137 if param_hash[:key_content]
138 should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({
139 "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}",
140 "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}",
141 "before" => "File[#{title}.list]"
144 should contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({
145 "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}",
146 "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}",
147 "before" => "File[#{title}.list]"
151 should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({
152 "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}",
153 "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}",
154 "before" => "File[#{title}.list]"