]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apt/recipes/default.rb
Drop brightbox ruby repository which hasn't been used for ages
[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 "644"
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 "644"
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 "ubuntugis-stable" do
62   action repository_actions["ubuntugis-stable"]
63   uri "ppa:ubuntugis/ppa"
64 end
65
66 apt_repository "ubuntugis-unstable" do
67   action repository_actions["ubuntugis-unstable"]
68   uri "ppa:ubuntugis/ubuntugis-unstable"
69 end
70
71 apt_repository "git-core" do
72   action repository_actions["git-core"]
73   uri "ppa:git-core/ppa"
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   only_if { node[:lsb][:release].to_f < 22.04 }
85 end
86
87 apt_repository "management-component-pack" do
88   action repository_actions["management-component-pack"]
89   uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
90   distribution "bionic/current-gen9"
91   components ["non-free"]
92   key "C208ADDE26C2B797"
93 end
94
95 apt_repository "hwraid" do
96   action repository_actions["hwraid"]
97   uri "https://hwraid.le-vert.net/ubuntu"
98   distribution "precise"
99   components ["main"]
100   key "6005210E23B3D3B4"
101 end
102
103 apt_repository "nginx" do
104   action repository_actions["nginx"]
105   arch "amd64"
106   uri "https://nginx.org/packages/ubuntu"
107   components ["nginx"]
108   key "ABF5BD827BD9BF62"
109 end
110
111 apt_repository "elasticsearch5.x" do
112   action repository_actions["elasticsearch5.x"]
113   uri "https://artifacts.elastic.co/packages/5.x/apt"
114   distribution "stable"
115   components ["main"]
116   key "D27D666CD88E42B4"
117 end
118
119 apt_repository "elasticsearch6.x" do
120   action repository_actions["elasticsearch6.x"]
121   uri "https://artifacts.elastic.co/packages/6.x/apt"
122   distribution "stable"
123   components ["main"]
124   key "D27D666CD88E42B4"
125 end
126
127 apt_repository "passenger" do
128   action repository_actions["passenger"]
129   uri "https://oss-binaries.phusionpassenger.com/apt/passenger"
130   components ["main"]
131   key "561F9B9CAC40B2F7"
132 end
133
134 apt_repository "postgresql" do
135   action repository_actions["postgresql"]
136   uri "https://apt.postgresql.org/pub/repos/apt"
137   distribution "#{node[:lsb][:codename]}-pgdg"
138   components ["main"]
139   key "7FCC7D46ACCC4CF8"
140 end
141
142 apt_repository "docker" do
143   action repository_actions["docker"]
144   uri "https://download.docker.com/linux/ubuntu"
145   arch "amd64"
146   components ["stable"]
147   key "https://download.docker.com/linux/ubuntu/gpg"
148 end
149
150 apt_repository "grafana" do
151   action repository_actions["grafana"]
152   uri "https://packages.grafana.com/enterprise/deb"
153   distribution "stable"
154   components ["main"]
155   key "https://packages.grafana.com/gpg.key"
156 end
157
158 apt_repository "timescaledb" do
159   action repository_actions["timescaledb"]
160   uri "https://packagecloud.io/timescale/timescaledb/ubuntu"
161   components ["main"]
162   key "https://packagecloud.io/timescale/timescaledb/gpgkey"
163 end
164
165 package "unattended-upgrades"
166
167 if Dir.exist?("/usr/share/unattended-upgrades")
168   auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
169                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
170                   else
171                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
172                   end
173
174   file "/etc/apt/apt.conf.d/20auto-upgrades" do
175     user "root"
176     group "root"
177     mode "644"
178     content auto_upgrades
179   end
180 end
181
182 template "/etc/apt/apt.conf.d/60chef" do
183   source "apt.conf.erb"
184   owner "root"
185   group "root"
186   mode "644"
187 end