From 6d911fcd56e6d9d53dc3b783a388a50413a47208 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Tue, 27 Jun 2023 09:51:52 +0200 Subject: [PATCH 1/2] Support Debian 12 In particular with Debian 11->12 systemd-resolved is now a sub package that must be installed. --- README.md | 2 +- spec/acceptance/resolved_spec.rb | 7 +++++-- spec/classes/init_spec.rb | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a08c304a..d375e10e 100644 --- a/README.md +++ b/README.md @@ -351,7 +351,7 @@ class { 'systemd': } ``` -when `manage_systemd` is true any required sub package, e.g. `systemd-resolved` on CentOS 9, will be installed. However configuration of +when `manage_systemd` is true any required sub package, e.g. `systemd-resolved` on CentOS 9 or Debian 12, will be installed. However configuration of systemd-resolved will only occur on second puppet run after that installation. This requires [puppetlabs-inifile](https://forge.puppet.com/puppetlabs/inifile), which is only a soft dependency in this module (you need to explicitly install it). Both parameters accept a string or an array. diff --git a/spec/acceptance/resolved_spec.rb b/spec/acceptance/resolved_spec.rb index 146b42b3..a786492f 100644 --- a/spec/acceptance/resolved_spec.rb +++ b/spec/acceptance/resolved_spec.rb @@ -12,8 +12,11 @@ } PUPPET apply_manifest(pp, catch_failures: true) - # RedHat 7, 9 and newer installs package first run before fact $facts['internal_services'] is set - apply_manifest(pp, catch_failures: true) if fact('os.release.major') != '8' && (fact('os.family') == 'RedHat') + # RedHat 7, 9, Debian 12 and newer installs package first run before fact $facts['internal_services'] is set + if (fact('os.release.major') != '8' && (fact('os.family') == 'RedHat')) || + ((fact('os.name') == 'Debian' && fact('os.release.major').to_i >= 12)) + apply_manifest(pp, catch_failures: true) + end apply_manifest(pp, catch_changes: true) end diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 4344ffa2..fcc09152 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -47,7 +47,7 @@ end case [facts[:os]['family'], facts[:os]['release']['major']] - when %w[RedHat 7], %w[RedHat 9] + when %w[RedHat 7], %w[RedHat 9], %w[Debian 12] it { is_expected.to contain_package('systemd-resolved') } else it { is_expected.not_to contain_package('systemd-resolved') } From f341931d072d07193081f310a91f0eeb2b1fea01 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Sun, 29 Oct 2023 23:24:11 +0100 Subject: [PATCH 2/2] Assert systemd-resolved is installed --- spec/acceptance/resolved_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/resolved_spec.rb b/spec/acceptance/resolved_spec.rb index a786492f..3f2776e9 100644 --- a/spec/acceptance/resolved_spec.rb +++ b/spec/acceptance/resolved_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper_acceptance' describe 'systemd with manage_resolved true' do + has_package = (fact('os.family') == 'RedHat' && fact('os.release.major') != '8') || (fact('os.name') == 'Debian' && fact('os.release.major').to_i >= 12) + context 'configure systemd resolved' do it 'works idempotently with no errors' do pp = <<-PUPPET @@ -13,10 +15,7 @@ PUPPET apply_manifest(pp, catch_failures: true) # RedHat 7, 9, Debian 12 and newer installs package first run before fact $facts['internal_services'] is set - if (fact('os.release.major') != '8' && (fact('os.family') == 'RedHat')) || - ((fact('os.name') == 'Debian' && fact('os.release.major').to_i >= 12)) - apply_manifest(pp, catch_failures: true) - end + apply_manifest(pp, catch_failures: true) if has_package apply_manifest(pp, catch_changes: true) end @@ -24,6 +23,8 @@ it { is_expected.to be_running } it { is_expected.to be_enabled } end + + it { expect(package('systemd-resolved')).to be_installed } if has_package end context 'configure systemd stopped' do