5 # Copyright:: 2010, Tom Hughes
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
11 # https://www.apache.org/licenses/LICENSE-2.0
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.
26 package "update-notifier-common" if platform?("ubuntu")
28 file "/etc/motd.tail" do
32 apt_preference "cciss-vol-status" do
33 pin "origin *.ubuntu.com"
37 apt_update "/etc/apt/sources.list" do
41 dpkg_arch = node[:packages][:systemd][:arch]
43 if platform?("debian")
44 archive_host = "deb.debian.org"
45 archive_security_host = archive_host
46 archive_distro = "debian"
47 archive_security_distro = "debian-security"
48 archive_suites = %w[main updates backports security]
49 archive_components = %w[main contrib non-free non-free-firmware]
50 backport_packages = case node[:lsb][:codename]
51 when "bookworm" then %W[amd64-microcode exim4 firmware-free firmware-nonfree intel-microcode libosmium linux linux-base linux-signed-#{dpkg_arch} osm2pgsql otrs2 pyosmium smartmontools systemd cgi-mapserver]
52 when "trixie" then %w[otrs2]
56 archive_host = if node[:country]
57 "#{node[:country]}.archive.ubuntu.com"
61 archive_security_host = "security.ubuntu.com"
62 archive_distro = "ubuntu"
63 archive_security_distro = archive_distro
64 archive_suites = %w[main updates backports security]
65 archive_components = %w[main restricted universe multiverse]
66 backport_packages = %w[]
68 archive_host = "ports.ubuntu.com"
69 archive_security_host = archive_host
70 archive_distro = "ubuntu-ports"
71 archive_security_distro = archive_distro
72 archive_suites = %w[main updates backports security]
73 archive_components = %w[main restricted universe multiverse]
74 backport_packages = %w[]
77 template "/etc/apt/sources.list" do
78 source "sources.list.erb"
82 variables :archive_host => archive_host,
83 :archive_security_host => archive_security_host,
84 :archive_distro => archive_distro,
85 :archive_security_distro => archive_security_distro,
86 :archive_suites => archive_suites,
87 :archive_components => archive_components,
88 :codename => node[:lsb][:codename]
89 notifies :update, "apt_update[/etc/apt/sources.list]", :immediately
92 if backport_packages.empty?
93 apt_preference "backports" do
97 apt_preference "backports" do
98 glob backport_packages.sort.map { |p| "src:#{p}" }.join(" ")
99 pin "release n=#{node[:lsb][:codename]}-backports"
104 execute "apt-cache-gencaches" do
106 command "apt-cache gencaches"
107 subscribes :run, "apt_preference[backports]", :immediately
110 apt_repository "openstreetmap" do
111 uri "https://apt.openstreetmap.org"
113 key "https://apt.openstreetmap.org/gpg.key"
116 package "unattended-upgrades"
118 if Dir.exist?("/usr/share/unattended-upgrades")
119 auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
120 IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
122 IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
125 file "/etc/apt/apt.conf.d/20auto-upgrades" do
129 content auto_upgrades
133 template "/etc/apt/apt.conf.d/60chef" do
134 source "apt.conf.erb"