From 0b195a2f666a0f15456ad801722bc77ee0c02e5a Mon Sep 17 00:00:00 2001 From: Shubham Shinde Date: Wed, 23 Oct 2024 00:07:13 +0530 Subject: [PATCH] (CAT-2100) Add Debian 12 support Adjust configs as per ntpsec which runs on Debian 12 in favour of ntp. --- .fixtures.yml | 2 +- manifests/config.pp | 6 +++++- metadata.json | 3 ++- .../ntp_user_and_daemon_opts_spec.rb | 19 +++++++++++++++++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 865b6470..22ccb531 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -6,7 +6,7 @@ fixtures: provision: "https://github.com/puppetlabs/provision.git" puppet_agent: repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - ref: v4.13.0 + ref: v4.21.0 package: "https://github.com/puppetlabs/puppetlabs-package.git" deploy_pe: "https://github.com/jarretlavallee/puppet-deploy_pe" sign_cert: "https://github.com/m0dular/sign_cert" diff --git a/manifests/config.pp b/manifests/config.pp index a3554cfa..e2865c74 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -33,7 +33,11 @@ } } 'Debian': { - $daemon_config = '/etc/default/ntp' + if $facts['os']['release']['major'] == '12' { + $daemon_config = '/etc/ntpsec/ntp.conf' + } else { + $daemon_config = '/etc/default/ntp' + } if $ntp::daemon_extra_opts { file_line { 'Set NTPD daemon options': ensure => present, diff --git a/metadata.json b/metadata.json index 441fe04d..74e45ac4 100644 --- a/metadata.json +++ b/metadata.json @@ -49,7 +49,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "10", - "11" + "11", + "12" ] }, { diff --git a/spec/acceptance/ntp_user_and_daemon_opts_spec.rb b/spec/acceptance/ntp_user_and_daemon_opts_spec.rb index 8a65e686..9c3cf81e 100644 --- a/spec/acceptance/ntp_user_and_daemon_opts_spec.rb +++ b/spec/acceptance/ntp_user_and_daemon_opts_spec.rb @@ -17,6 +17,8 @@ else servicename = if os[:family] == 'sles' && os[:release].start_with?('12', '15') 'ntpd' + elsif os[:family] == 'debian' && os[:release].start_with?('12') + 'ntpsec' else 'ntp' end @@ -25,11 +27,24 @@ '/etc/sysconfig/ntpd' elsif os[:family] == 'sles' '/etc/sysconfig/ntp' + elsif os[:family] == 'debian' && os[:release].start_with?('12') + '/etc/ntpsec/ntp.conf' else '/etc/default/ntp' end + +if os[:family] == 'debian' && os[:release].start_with?('12') + ntpd_opts_match = %r{(OPTIONS|NTPD_OPTS)='-g -i /var/lib/ntpsec'} + chroot_dir = '/var/lib/ntpsec' +else + ntpd_opts_match = %r{(OPTIONS|NTPD_OPTS)='-g -i /var/lib/ntp'} + chroot_dir = '/var/lib/ntp' +end + describe 'ntp class with daemon options:', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) || (os[:release].start_with?('5') && os[:family] == 'redhat') do - let(:pp) { "class { 'ntp': service_enable => true, service_ensure => running, service_manage => true, service_name => '#{servicename}', user => 'ntp', daemon_extra_opts => '-g -i /var/lib/ntp' }" } + let(:pp) do + "class { 'ntp': service_enable => true, service_ensure => running, service_manage => true, service_name => '#{servicename}', user => 'ntp', daemon_extra_opts => '-g -i #{chroot_dir}' }" + end context 'when run' do it 'is successful' do # rubocop:disable RSpec/NoExpectationExample @@ -37,7 +52,7 @@ end describe file(config.to_s) do - its(:content) { is_expected.to match(%r{(OPTIONS|NTPD_OPTS)='-g -i /var/lib/ntp'}) } + its(:content) { is_expected.to match(ntpd_opts_match) } end if os[:family] == 'redhat' && !os[:release].start_with?('6')