]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apt/recipes/default.rb
Add initial support for other ubuntu ports (eg: arm64)
[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 if node[:kernel][:machine] == "x86_64"
43   archive_host = if node[:country]
44                    "#{node[:country]}.archive.ubuntu.com"
45                  else
46                    "archive.ubuntu.com"
47                  end
48   archive_security_host = "security.ubuntu.com"
49   archive_distro = "ubuntu"
50 else
51   archive_host = "ports.ubuntu.com"
52   archive_security_host = archive_host
53   archive_distro = "ubuntu-ports"
54 end
55
56 template "/etc/apt/sources.list" do
57   source "sources.list.erb"
58   owner "root"
59   group "root"
60   mode "644"
61   variables :archive_host => archive_host, :archive_security_host => archive_security_host, :archive_distro => archive_distro, :codename => node[:lsb][:codename]
62   notifies :update, "apt_update[/etc/apt/sources.list]", :immediately
63 end
64
65 repository_actions = Hash.new do |_, repository|
66   node[:apt][:sources].include?(repository) ? :add : :remove
67 end
68
69 apt_repository "ubuntugis-stable" do
70   action repository_actions["ubuntugis-stable"]
71   uri "ppa:ubuntugis/ppa"
72 end
73
74 apt_repository "ubuntugis-unstable" do
75   action repository_actions["ubuntugis-unstable"]
76   uri "ppa:ubuntugis/ubuntugis-unstable"
77 end
78
79 apt_repository "git-core" do
80   action repository_actions["git-core"]
81   uri "ppa:git-core/ppa"
82 end
83
84 apt_repository "maxmind" do
85   action repository_actions["maxmind"]
86   uri "ppa:maxmind/ppa"
87 end
88
89 apt_repository "openstreetmap" do
90   action repository_actions["openstreetmap"]
91   uri "ppa:osmadmins/ppa"
92 end
93
94 apt_repository "management-component-pack" do
95   action repository_actions["management-component-pack"]
96   uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
97   distribution "bionic/current-gen9"
98   components ["non-free"]
99   key "C208ADDE26C2B797"
100 end
101
102 apt_repository "hwraid" do
103   action repository_actions["hwraid"]
104   uri "https://hwraid.le-vert.net/ubuntu"
105   distribution "precise"
106   components ["main"]
107   key "6005210E23B3D3B4"
108 end
109
110 apt_repository "nginx" do
111   action repository_actions["nginx"]
112   arch "amd64"
113   uri "https://nginx.org/packages/ubuntu"
114   components ["nginx"]
115   key "ABF5BD827BD9BF62"
116 end
117
118 apt_repository "elasticsearch6.x" do
119   action repository_actions["elasticsearch6.x"]
120   uri "https://artifacts.elastic.co/packages/6.x/apt"
121   distribution "stable"
122   components ["main"]
123   key "D27D666CD88E42B4"
124 end
125
126 apt_repository "elasticsearch8.x" do
127   action repository_actions["elasticsearch8.x"]
128   uri "https://artifacts.elastic.co/packages/8.x/apt"
129   distribution "stable"
130   components ["main"]
131   key "D27D666CD88E42B4"
132 end
133
134 apt_repository "passenger" do
135   action repository_actions["passenger"]
136   uri "https://oss-binaries.phusionpassenger.com/apt/passenger"
137   components ["main"]
138   key "561F9B9CAC40B2F7"
139 end
140
141 apt_repository "postgresql" do
142   action repository_actions["postgresql"]
143   uri "https://apt.postgresql.org/pub/repos/apt"
144   distribution "#{node[:lsb][:codename]}-pgdg"
145   components ["main"]
146   key "7FCC7D46ACCC4CF8"
147 end
148
149 apt_repository "docker" do
150   action repository_actions["docker"]
151   uri "https://download.docker.com/linux/ubuntu"
152   arch "amd64"
153   components ["stable"]
154   key "https://download.docker.com/linux/ubuntu/gpg"
155 end
156
157 apt_repository "grafana" do
158   action repository_actions["grafana"]
159   uri "https://packages.grafana.com/enterprise/deb"
160   distribution "stable"
161   components ["main"]
162   key "https://packages.grafana.com/gpg.key"
163 end
164
165 apt_repository "timescaledb" do
166   action repository_actions["timescaledb"]
167   uri "https://packagecloud.io/timescale/timescaledb/ubuntu"
168   components ["main"]
169   key "https://packagecloud.io/timescale/timescaledb/gpgkey"
170 end
171
172 package "unattended-upgrades"
173
174 if Dir.exist?("/usr/share/unattended-upgrades")
175   auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
176                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
177                   else
178                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
179                   end
180
181   file "/etc/apt/apt.conf.d/20auto-upgrades" do
182     user "root"
183     group "root"
184     mode "644"
185     content auto_upgrades
186   end
187 end
188
189 template "/etc/apt/apt.conf.d/60chef" do
190   source "apt.conf.erb"
191   owner "root"
192   group "root"
193   mode "644"
194 end