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]
 
  55   archive_host = if node[:country]
 
  56                    "#{node[:country]}.archive.ubuntu.com"
 
  60   archive_security_host = "security.ubuntu.com"
 
  61   archive_distro = "ubuntu"
 
  62   archive_security_distro = archive_distro
 
  63   archive_suites = %w[main updates backports security]
 
  64   archive_components = %w[main restricted universe multiverse]
 
  65   backport_packages = %w[]
 
  67   archive_host = "ports.ubuntu.com"
 
  68   archive_security_host = archive_host
 
  69   archive_distro = "ubuntu-ports"
 
  70   archive_security_distro = archive_distro
 
  71   archive_suites = %w[main updates backports security]
 
  72   archive_components = %w[main restricted universe multiverse]
 
  73   backport_packages = %w[]
 
  76 template "/etc/apt/sources.list" do
 
  77   source "sources.list.erb"
 
  81   variables :archive_host => archive_host,
 
  82             :archive_security_host => archive_security_host,
 
  83             :archive_distro => archive_distro,
 
  84             :archive_security_distro => archive_security_distro,
 
  85             :archive_suites => archive_suites,
 
  86             :archive_components => archive_components,
 
  87             :codename => node[:lsb][:codename]
 
  88   notifies :update, "apt_update[/etc/apt/sources.list]", :immediately
 
  91 if backport_packages.empty?
 
  92   apt_preference "backports" do
 
  96   apt_preference "backports" do
 
  97     glob backport_packages.sort.map { |p| "src:#{p}" }.join(" ")
 
  98     pin "release n=#{node[:lsb][:codename]}-backports"
 
 103 execute "apt-cache-gencaches" do
 
 105   command "apt-cache gencaches"
 
 106   subscribes :run, "apt_preference[backports]", :immediately
 
 109 apt_repository "openstreetmap" do
 
 110   uri "https://apt.openstreetmap.org"
 
 112   key "https://apt.openstreetmap.org/gpg.key"
 
 115 package "unattended-upgrades"
 
 117 if Dir.exist?("/usr/share/unattended-upgrades")
 
 118   auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
 
 119                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
 
 121                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
 
 124   file "/etc/apt/apt.conf.d/20auto-upgrades" do
 
 128     content auto_upgrades
 
 132 template "/etc/apt/apt.conf.d/60chef" do
 
 133   source "apt.conf.erb"