]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apt/recipes/default.rb
Enable both the jammy and focal HP repos for Gen10 machines
[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 intel?
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 apt_repository "openstreetmap" do
66   uri "ppa:osmadmins/ppa"
67 end
68
69 package "unattended-upgrades"
70
71 if Dir.exist?("/usr/share/unattended-upgrades")
72   auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
73                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
74                   else
75                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
76                   end
77
78   file "/etc/apt/apt.conf.d/20auto-upgrades" do
79     user "root"
80     group "root"
81     mode "644"
82     content auto_upgrades
83   end
84 end
85
86 template "/etc/apt/apt.conf.d/60chef" do
87   source "apt.conf.erb"
88   owner "root"
89   group "root"
90   mode "644"
91 end