]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apt/recipes/default.rb
Add tests for web cookbook
[chef.git] / cookbooks / apt / recipes / default.rb
1 #
2 # Cookbook:: apt
3 # Recipe:: default
4 #
5 # Copyright:: 2010, Tom Hughes
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 package %w[
21   apt
22   apt-transport-https
23   gnupg
24   update-notifier-common
25 ]
26
27 file "/etc/motd.tail" do
28   action :delete
29 end
30
31 template "/etc/apt/preferences.d/99-chef" do
32   source "preferences.erb"
33   owner "root"
34   group "root"
35   mode 0o644
36 end
37
38 apt_update "/etc/apt/sources.list" do
39   action :nothing
40 end
41
42 archive_host = if node[:country]
43                  "#{node[:country]}.archive.ubuntu.com"
44                else
45                  "archive.ubuntu.com"
46                end
47
48 template "/etc/apt/sources.list" do
49   source "sources.list.erb"
50   owner "root"
51   group "root"
52   mode 0o644
53   variables :archive_host => archive_host, :codename => node[:lsb][:codename]
54   notifies :update, "apt_update[/etc/apt/sources.list]", :immediately
55 end
56
57 repository_actions = Hash.new do |_, repository|
58   node[:apt][:sources].include?(repository) ? :add : :remove
59 end
60
61 apt_repository "brightbox-ruby-ng" do
62   action repository_actions["brightbox-ruby-ng"]
63   uri "ppa:brightbox/ruby-ng"
64 end
65
66 apt_repository "ubuntugis-stable" do
67   action repository_actions["ubuntugis-stable"]
68   uri "ppa:ubuntugis/ppa"
69 end
70
71 apt_repository "ubuntugis-unstable" do
72   action repository_actions["ubuntugis-unstable"]
73   uri "ppa:ubuntugis/ubuntugis-unstable"
74 end
75
76 apt_repository "maxmind" do
77   action repository_actions["maxmind"]
78   uri "ppa:maxmind/ppa"
79 end
80
81 apt_repository "openstreetmap" do
82   action repository_actions["openstreetmap"]
83   uri "ppa:osmadmins/ppa"
84 end
85
86 apt_repository "squid2" do
87   action repository_actions["squid2"]
88   uri "ppa:osmadmins/squid2"
89 end
90
91 apt_repository "squid3" do
92   action repository_actions["squid3"]
93   uri "ppa:osmadmins/squid3"
94 end
95
96 apt_repository "squid4" do
97   action repository_actions["squid4"]
98   uri "ppa:osmadmins/squid4"
99 end
100
101 apt_repository "management-component-pack" do
102   action repository_actions["management-component-pack"]
103   uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
104   distribution "#{node[:lsb][:codename]}/current-gen9"
105   components ["non-free"]
106   key "C208ADDE26C2B797"
107 end
108
109 apt_repository "hwraid" do
110   action repository_actions["hwraid"]
111   uri "https://hwraid.le-vert.net/ubuntu"
112   distribution "precise"
113   components ["main"]
114   key "6005210E23B3D3B4"
115 end
116
117 apt_repository "nginx" do
118   action repository_actions["nginx"]
119   arch "amd64"
120   uri "https://nginx.org/packages/ubuntu"
121   components ["nginx"]
122   key "ABF5BD827BD9BF62"
123 end
124
125 apt_repository "elasticsearch5.x" do
126   action repository_actions["elasticsearch5.x"]
127   uri "https://artifacts.elastic.co/packages/5.x/apt"
128   distribution "stable"
129   components ["main"]
130   key "D27D666CD88E42B4"
131 end
132
133 apt_repository "elasticsearch6.x" do
134   action repository_actions["elasticsearch6.x"]
135   uri "https://artifacts.elastic.co/packages/6.x/apt"
136   distribution "stable"
137   components ["main"]
138   key "D27D666CD88E42B4"
139 end
140
141 apt_repository "passenger" do
142   action repository_actions["passenger"]
143   uri "https://oss-binaries.phusionpassenger.com/apt/passenger"
144   components ["main"]
145   key "561F9B9CAC40B2F7"
146 end
147
148 apt_repository "postgresql" do
149   action repository_actions["postgresql"]
150   uri "https://apt.postgresql.org/pub/repos/apt"
151   distribution "#{node[:lsb][:codename]}-pgdg"
152   components ["main"]
153   key "7FCC7D46ACCC4CF8"
154 end
155
156 apt_repository "mediawiki" do
157   action repository_actions["mediawiki"]
158   uri "https://releases.wikimedia.org/debian"
159   distribution "jessie-mediawiki"
160   components ["main"]
161   key "AF380A3036A03444"
162 end
163
164 package "unattended-upgrades"
165
166 if Dir.exist?("/usr/share/unattended-upgrades")
167   auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
168                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
169                   else
170                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
171                   end
172
173   file "/etc/apt/apt.conf.d/20auto-upgrades" do
174     user "root"
175     group "root"
176     mode 0o644
177     content auto_upgrades
178   end
179 end
180
181 template "/etc/apt/apt.conf.d/60chef" do
182   source "apt.conf.erb"
183   owner "root"
184   group "root"
185   mode 0o644
186 end