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'
34 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
36 param_set == {} ? default_params : params
44 "/etc/apt/sources.list.d/#{title}.list"
48 content = "# #{title}"
49 content << "\ndeb #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
50 if param_hash[:include_src]
51 content << "deb-src #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
56 it { should contain_apt__params }
58 it { should contain_file("#{title}.list").with({
70 should contain_apt__pin(param_hash[:release]).with({
71 "priority" => param_hash[:pin],
72 "before" => "File[#{title}.list]"
75 should_not contain_apt__pin(param_hash[:release]).with({
76 "priority" => param_hash[:pin],
77 "before" => "File[#{title}.list]"
83 should contain_exec("#{title} apt update").with({
84 "command" => "/usr/bin/apt-get update",
85 "subscribe" => "File[#{title}.list]",
91 if param_hash[:required_packages]
92 should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
93 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
94 "subscribe" => "File[#{title}.list]",
98 should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
99 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
100 "subscribe" => "File[#{title}.list]",
101 "refreshonly" => true
108 if param_hash[:key_content]
109 should contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({
110 "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -",
111 "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'",
112 "before" => "File[#{title}.list]"
114 should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({
115 "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}",
116 "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}",
117 "before" => "File[#{title}.list]"
121 should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({
122 "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -",
123 "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'",
124 "before" => "File[#{title}.list]"
126 should contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({
127 "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}",
128 "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}",
129 "before" => "File[#{title}.list]"
133 should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({
134 "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -",
135 "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'",
136 "before" => "File[#{title}.list]"
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]"