]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apt/recipes/default.rb
14e37dd9b6ba75a29cb62383c3c8ed7c7873dcfd
[chef.git] / cookbooks / apt / recipes / default.rb
1 #
2 # Cookbook Name:: 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 "openstreetmap" do
77   action repository_actions["openstreetmap"]
78   uri "ppa:osmadmins/ppa"
79 end
80
81 apt_repository "squid2" do
82   action repository_actions["squid2"]
83   uri "ppa:osmadmins/squid2"
84 end
85
86 apt_repository "squid3" do
87   action repository_actions["squid3"]
88   uri "ppa:osmadmins/squid3"
89 end
90
91 apt_repository "management-component-pack" do
92   action repository_actions["management-component-pack"]
93   uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
94   distribution "#{node[:lsb][:codename]}/current-gen9"
95   components ["non-free"]
96   key "C208ADDE26C2B797"
97 end
98
99 apt_repository "hwraid" do
100   action repository_actions["hwraid"]
101   uri "https://hwraid.le-vert.net/ubuntu"
102   distribution "precise"
103   components ["main"]
104   key "6005210E23B3D3B4"
105 end
106
107 apt_repository "nginx" do
108   action repository_actions["nginx"]
109   arch "amd64"
110   uri "https://nginx.org/packages/ubuntu"
111   components ["nginx"]
112   key "ABF5BD827BD9BF62"
113 end
114
115 apt_repository "elasticsearch5.x" do
116   action repository_actions["elasticsearch5.x"]
117   uri "https://artifacts.elastic.co/packages/5.x/apt"
118   distribution "stable"
119   components ["main"]
120   key "D27D666CD88E42B4"
121 end
122
123 apt_repository "elasticsearch6.x" do
124   action repository_actions["elasticsearch6.x"]
125   uri "https://artifacts.elastic.co/packages/6.x/apt"
126   distribution "stable"
127   components ["main"]
128   key "D27D666CD88E42B4"
129 end
130
131 apt_repository "passenger" do
132   action repository_actions["passenger"]
133   uri "https://oss-binaries.phusionpassenger.com/apt/passenger"
134   components ["main"]
135   key "561F9B9CAC40B2F7"
136 end
137
138 apt_repository "postgresql" do
139   action repository_actions["postgresql"]
140   uri "https://apt.postgresql.org/pub/repos/apt"
141   distribution "#{node[:lsb][:codename]}-pgdg"
142   components ["main"]
143   key "7FCC7D46ACCC4CF8"
144 end
145
146 apt_repository "mediawiki" do
147   action repository_actions["mediawiki"]
148   uri "https://releases.wikimedia.org/debian"
149   distribution "jessie-mediawiki"
150   components ["main"]
151   key "90E9F83F22250DD7"
152 end
153
154 package "unattended-upgrades"
155
156 if Dir.exist?("/usr/share/unattended-upgrades")
157   auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
158                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
159                   else
160                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
161                   end
162
163   file "/etc/apt/apt.conf.d/20auto-upgrades" do
164     user "root"
165     group "root"
166     mode 0o644
167     content auto_upgrades
168   end
169 end
170
171 template "/etc/apt/apt.conf.d/60chef" do
172   source "apt.conf.erb"
173   owner "root"
174   group "root"
175   mode 0o644
176 end