From 86a29665df0d85ab17a421debd7c16e8216dc688 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 21 Mar 2023 20:45:54 +0000 Subject: [PATCH 1/1] Get apt configuration working on debian --- cookbooks/apt/recipes/default.rb | 27 ++++++++-- cookbooks/apt/recipes/docker.rb | 10 +++- cookbooks/apt/recipes/hwraid.rb | 16 +++++- .../apt/recipes/management-component-pack.rb | 54 ++++++++++++------- cookbooks/apt/recipes/maxmind.rb | 1 + cookbooks/apt/recipes/nginx.rb | 8 ++- cookbooks/apt/recipes/timescaledb.rb | 8 ++- .../apt/templates/default/sources.list.erb | 53 ++++++------------ 8 files changed, 113 insertions(+), 64 deletions(-) diff --git a/cookbooks/apt/recipes/default.rb b/cookbooks/apt/recipes/default.rb index c92865b55..47bd0ad18 100644 --- a/cookbooks/apt/recipes/default.rb +++ b/cookbooks/apt/recipes/default.rb @@ -21,9 +21,10 @@ package %w[ apt apt-transport-https gnupg - update-notifier-common ] +package "update-notifier-common" if platform?("ubuntu") + file "/etc/motd.tail" do action :delete end @@ -42,7 +43,14 @@ apt_update "/etc/apt/sources.list" do action :nothing end -if intel? +if platform?("debian") + archive_host = "deb.debian.org" + archive_security_host = archive_host + archive_distro = "debian" + archive_security_distro = "debian-security" + archive_suites = %w[main updates security] + archive_components = %w[main contrib non-free] +elsif intel? archive_host = if node[:country] "#{node[:country]}.archive.ubuntu.com" else @@ -50,10 +58,16 @@ if intel? end archive_security_host = "security.ubuntu.com" archive_distro = "ubuntu" + archive_security_distro = archive_distro + archive_suites = %w[main updates backports security] + archive_components = %w[main restricted universe multiverse] else archive_host = "ports.ubuntu.com" archive_security_host = archive_host archive_distro = "ubuntu-ports" + archive_security_distro = archive_distro + archive_suites = %w[main updates backports security] + archive_components = %w[main restricted universe multiverse] end template "/etc/apt/sources.list" do @@ -61,12 +75,19 @@ template "/etc/apt/sources.list" do owner "root" group "root" mode "644" - variables :archive_host => archive_host, :archive_security_host => archive_security_host, :archive_distro => archive_distro, :codename => node[:lsb][:codename] + variables :archive_host => archive_host, + :archive_security_host => archive_security_host, + :archive_distro => archive_distro, + :archive_security_distro => archive_security_distro, + :archive_suites => archive_suites, + :archive_components => archive_components, + :codename => node[:lsb][:codename] notifies :update, "apt_update[/etc/apt/sources.list]", :immediately end apt_repository "openstreetmap" do uri "ppa:osmadmins/ppa" + only_if { platform?("ubuntu") } end package "unattended-upgrades" diff --git a/cookbooks/apt/recipes/docker.rb b/cookbooks/apt/recipes/docker.rb index 7c8780779..2aeb832e3 100644 --- a/cookbooks/apt/recipes/docker.rb +++ b/cookbooks/apt/recipes/docker.rb @@ -19,6 +19,12 @@ include_recipe "apt" +docker_platform = if platform?("debian") + "debian" + else + "ubuntu" + end + docker_arch = if arm? "arm64" else @@ -26,8 +32,8 @@ docker_arch = if arm? end apt_repository "docker" do - uri "https://download.docker.com/linux/ubuntu" + uri "https://download.docker.com/linux/#{docker_platform}" arch docker_arch components ["stable"] - key "https://download.docker.com/linux/ubuntu/gpg" + key "https://download.docker.com/linux/#{docker_platform}/gpg" end diff --git a/cookbooks/apt/recipes/hwraid.rb b/cookbooks/apt/recipes/hwraid.rb index aa5a7fb91..fa5d9e1f9 100644 --- a/cookbooks/apt/recipes/hwraid.rb +++ b/cookbooks/apt/recipes/hwraid.rb @@ -19,9 +19,21 @@ include_recipe "apt" +platform_name = if platform?("debian") + "debian" + else + "ubuntu" + end + +distribution_name = if platform?("debian") + "buster" + else + "precise" + end + apt_repository "hwraid" do - uri "https://hwraid.le-vert.net/ubuntu" - distribution "precise" + uri "https://hwraid.le-vert.net/#{platform_name}" + distribution distribution_name components ["main"] key "6005210E23B3D3B4" end diff --git a/cookbooks/apt/recipes/management-component-pack.rb b/cookbooks/apt/recipes/management-component-pack.rb index 09b982d37..34aad4d5e 100644 --- a/cookbooks/apt/recipes/management-component-pack.rb +++ b/cookbooks/apt/recipes/management-component-pack.rb @@ -23,25 +23,43 @@ apt_repository "management-component-pack" do action :remove end -if node[:dmi][:system][:product_name].end_with?("Gen10") - apt_repository "mcp-jammy" do - uri "https://downloads.linux.hpe.com/SDR/repo/mcp" - distribution "jammy/current" - components ["non-free"] - key "C208ADDE26C2B797" +if platform?("debian") + if node[:dmi][:system][:product_name].end_with?("Gen10") + apt_repository "mcp-gen10" do + uri "https://downloads.linux.hpe.com/SDR/repo/mcp" + distribution "#{node[:lsb][:codename]}/current-gen10" + components ["non-free"] + key "C208ADDE26C2B797" + end + else + apt_repository "mcp" do + uri "https://downloads.linux.hpe.com/SDR/repo/mcp" + distribution "#{node[:lsb][:codename]}/current" + components ["non-free"] + key "C208ADDE26C2B797" + end end +elsif platform?("ubuntu") + if node[:dmi][:system][:product_name].end_with?("Gen10") + apt_repository "mcp-jammy" do + uri "https://downloads.linux.hpe.com/SDR/repo/mcp" + distribution "jammy/current" + components ["non-free"] + key "C208ADDE26C2B797" + end - apt_repository "mcp-focal-gen10" do - uri "https://downloads.linux.hpe.com/SDR/repo/mcp" - distribution "focal/current-gen10" - components ["non-free"] - key "C208ADDE26C2B797" - end -else - apt_repository "mcp-bionic-gen9" do - uri "https://downloads.linux.hpe.com/SDR/repo/mcp" - distribution "bionic/current-gen9" - components ["non-free"] - key "C208ADDE26C2B797" + apt_repository "mcp-focal-gen10" do + uri "https://downloads.linux.hpe.com/SDR/repo/mcp" + distribution "focal/current-gen10" + components ["non-free"] + key "C208ADDE26C2B797" + end + else + apt_repository "mcp-bionic-gen9" do + uri "https://downloads.linux.hpe.com/SDR/repo/mcp" + distribution "bionic/current-gen9" + components ["non-free"] + key "C208ADDE26C2B797" + end end end diff --git a/cookbooks/apt/recipes/maxmind.rb b/cookbooks/apt/recipes/maxmind.rb index a0029aae1..dbe0fc88a 100644 --- a/cookbooks/apt/recipes/maxmind.rb +++ b/cookbooks/apt/recipes/maxmind.rb @@ -21,4 +21,5 @@ include_recipe "apt" apt_repository "maxmind" do uri "ppa:maxmind/ppa" + only_if { platform?("ubuntu") } end diff --git a/cookbooks/apt/recipes/nginx.rb b/cookbooks/apt/recipes/nginx.rb index 63fad62fc..b80b8bb8b 100644 --- a/cookbooks/apt/recipes/nginx.rb +++ b/cookbooks/apt/recipes/nginx.rb @@ -19,9 +19,15 @@ include_recipe "apt" +platform_name = if platform?("debian") + "debian" + else + "ubuntu" + end + apt_repository "nginx" do arch "amd64" - uri "https://nginx.org/packages/ubuntu" + uri "https://nginx.org/packages/#{platform_name}" components ["nginx"] key "ABF5BD827BD9BF62" end diff --git a/cookbooks/apt/recipes/timescaledb.rb b/cookbooks/apt/recipes/timescaledb.rb index 57cccf2b2..5fc56c2d2 100644 --- a/cookbooks/apt/recipes/timescaledb.rb +++ b/cookbooks/apt/recipes/timescaledb.rb @@ -20,8 +20,14 @@ include_recipe "apt" include_recipe "apt::postgresql" +platform_name = if platform?("debian") + "debian" + else + "ubuntu" + end + apt_repository "timescaledb" do - uri "https://packagecloud.io/timescale/timescaledb/ubuntu" + uri "https://packagecloud.io/timescale/timescaledb/#{platform_name}" components ["main"] key "https://packagecloud.io/timescale/timescaledb/gpgkey" end diff --git a/cookbooks/apt/templates/default/sources.list.erb b/cookbooks/apt/templates/default/sources.list.erb index db8501e18..d514279b7 100644 --- a/cookbooks/apt/templates/default/sources.list.erb +++ b/cookbooks/apt/templates/default/sources.list.erb @@ -1,42 +1,21 @@ # DO NOT EDIT - This file is being maintained by Chef +<% if @archive_suites.include?("main") -%> -deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %> main restricted -# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %> main restricted +deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %> <%= @archive_components.join(" ") %> +# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %> <%= @archive_components.join(" ") %> +<% end -%> +<% if @archive_suites.include?("updates") -%> -## Major bug fix updates produced after the final release of the -## distribution. -deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-updates main restricted -# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-updates main restricted +deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-updates <%= @archive_components.join(" ") %> +# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-updates <%= @archive_components.join(" ") %> +<% end -%> +<% if @archive_suites.include?("backports") -%> -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team. Also, please note that software in universe WILL NOT receive any -## review or updates from the Ubuntu security team. -deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %> universe -# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %> universe -deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-updates universe -# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-updates universe +deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-backports <%= @archive_components.join(" ") %> +# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-backports <%= @archive_components.join(" ") %> +<% end -%> +<% if @archive_suites.include?("security") -%> -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## multiverse WILL NOT receive any review or updates from the Ubuntu -## security team. -deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %> multiverse -# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %> multiverse -deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-updates multiverse -# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-updates multiverse - -## N.B. software from this repository may not have been tested as -## extensively as that contained in the main release, although it includes -## newer versions of some applications which may provide useful features. -## Also, please note that software in backports WILL NOT receive any review -## or updates from the Ubuntu security team. -deb http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-backports main restricted universe multiverse -# deb-src http://<%= @archive_host %>/<%= @archive_distro %>/ <%= @codename %>-backports main restricted universe multiverse - -deb http://<%= @archive_security_host %>/<%= @archive_distro %>/ <%= @codename %>-security main restricted -# deb-src http://<%= @archive_security_host %>/<%= @archive_distro %>/ <%= @codename %>-security main restricted -deb http://<%= @archive_security_host %>/<%= @archive_distro %>/ <%= @codename %>-security universe -# deb-src http://<%= @archive_security_host %>/<%= @archive_distro %>/ <%= @codename %>-security universe -deb http://<%= @archive_security_host %>/<%= @archive_distro %>/ <%= @codename %>-security multiverse -# deb-src http://<%= @archive_security_host %>/<%= @archive_distro %>/ <%= @codename %>-security multiverse +deb http://<%= @archive_security_host %>/<%= @archive_security_distro %>/ <%= @codename %>-security <%= @archive_components.join(" ") %> +# deb-src http://<%= @archive_security_host %>/<%= @archive_security_distro %>/ <%= @codename %>-security <%= @archive_components.join(" ") %> +<% end -%> -- 2.39.5