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 if platform?("debian")
42 archive_host = "deb.debian.org"
43 archive_security_host = archive_host
44 archive_distro = "debian"
45 archive_security_distro = "debian-security"
46 archive_suites = %w[main updates backports security]
47 archive_components = %w[main contrib non-free non-free-firmware]
48 backport_packages = case node[:lsb][:codename]
49 when "bookworm" then %w[exim4 libosmium osm2pgsql otrs2 pyosmium smartmontools]
53 archive_host = if node[:country]
54 "#{node[:country]}.archive.ubuntu.com"
58 archive_security_host = "security.ubuntu.com"
59 archive_distro = "ubuntu"
60 archive_security_distro = archive_distro
61 archive_suites = %w[main updates backports security]
62 archive_components = %w[main restricted universe multiverse]
63 backport_packages = %w[]
65 archive_host = "ports.ubuntu.com"
66 archive_security_host = archive_host
67 archive_distro = "ubuntu-ports"
68 archive_security_distro = archive_distro
69 archive_suites = %w[main updates backports security]
70 archive_components = %w[main restricted universe multiverse]
71 backport_packages = %w[]
74 template "/etc/apt/sources.list" do
75 source "sources.list.erb"
79 variables :archive_host => archive_host,
80 :archive_security_host => archive_security_host,
81 :archive_distro => archive_distro,
82 :archive_security_distro => archive_security_distro,
83 :archive_suites => archive_suites,
84 :archive_components => archive_components,
85 :codename => node[:lsb][:codename]
86 notifies :update, "apt_update[/etc/apt/sources.list]", :immediately
89 if backport_packages.empty?
90 apt_preference "backports" do
94 apt_preference "backports" do
95 glob backport_packages.sort.map { |p| "src:#{p}" }.join(" ")
96 pin "release n=#{node[:lsb][:codename]}-backports"
101 execute "apt-cache-gencaches" do
103 command "apt-cache gencaches"
104 subscribes :run, "apt_preference[backports]", :immediately
107 apt_repository "openstreetmap" do
108 uri "https://apt.openstreetmap.org"
110 key "https://apt.openstreetmap.org/gpg.key"
113 package "unattended-upgrades"
115 if Dir.exist?("/usr/share/unattended-upgrades")
116 auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
117 IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
119 IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
122 file "/etc/apt/apt.conf.d/20auto-upgrades" do
126 content auto_upgrades
130 template "/etc/apt/apt.conf.d/60chef" do
131 source "apt.conf.erb"