diff --git a/data/Debian-12.yaml b/data/Debian-12.yaml new file mode 100644 index 00000000..0b82489a --- /dev/null +++ b/data/Debian-12.yaml @@ -0,0 +1,4 @@ +--- +ntp::package_name: + - ntpsec +ntp::config: '/etc/ntpsec/ntp.conf' diff --git a/data/Ubuntu-24.04.yaml b/data/Ubuntu-24.04.yaml new file mode 100644 index 00000000..0b82489a --- /dev/null +++ b/data/Ubuntu-24.04.yaml @@ -0,0 +1,4 @@ +--- +ntp::package_name: + - ntpsec +ntp::config: '/etc/ntpsec/ntp.conf' diff --git a/manifests/config.pp b/manifests/config.pp index e2865c74..b2191b3a 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -33,8 +33,22 @@ } } 'Debian': { - if $facts['os']['release']['major'] == '12' { - $daemon_config = '/etc/ntpsec/ntp.conf' + if $facts['os']['name'] == 'Ubuntu' { + # This ugly indentation is forced upon me by puppet-lint. I disclaim + # any responsibility for damage to your eyes. + if (versioncmp($facts['os']['release']['major'], '18.04') >= 0 and + versioncmp($facts['os']['release']['major'], '24.04') < 0 and + $ntp::user) { + file_line { 'Set NTPD daemon user': + ensure => present, + path => '/usr/lib/ntp/ntp-systemd-wrapper', + line => "RUNASUSER=${ntp::user}", + match => '^RUNASUSER\=', + } + } + } + if 'ntpsec' in $ntp::package_name { + $daemon_config = '/etc/default/ntpsec' } else { $daemon_config = '/etc/default/ntp' } @@ -46,14 +60,6 @@ match => '^NTPD_OPTS\=', } } - if $ntp::user and $facts['os']['release']['major'] == '18.04' { - file_line { 'Set NTPD daemon user': - ensure => present, - path => '/usr/lib/ntp/ntp-systemd-wrapper', - line => "RUNASUSER=${ntp::user}", - match => '^RUNASUSER\=', - } - } } 'Suse': { $daemon_config = '/etc/sysconfig/ntp' diff --git a/metadata.json b/metadata.json index cbf77954..9425a5fe 100644 --- a/metadata.json +++ b/metadata.json @@ -58,7 +58,8 @@ "operatingsystemrelease": [ "18.04", "20.04", - "22.04" + "22.04", + "24.04" ] }, { diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb index 6051de8c..ca267157 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -9,6 +9,10 @@ let(:conf_path) do if os.include?('solaris') '/etc/inet/ntp.conf' + elsif f[:os]['name'] == 'Debian' && f[:os]['release']['major'].to_f >= 12 + '/etc/ntpsec/ntp.conf' + elsif f[:os]['name'] == 'Ubuntu' && f[:os]['release']['major'].to_f >= 24.04 + '/etc/ntpsec/ntp.conf' else '/etc/ntp.conf' end @@ -132,7 +136,7 @@ case f[:os]['family'] when 'RedHat' it 'uses the centos ntp servers' do - expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.centos.pool.ntp.org}) + expect(subject).to contain_file(conf_path).with('content' => %r{server \d.centos.pool.ntp.org}) end it do @@ -140,15 +144,15 @@ end when 'Debian' it 'uses the debian ntp servers' do - expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.debian.pool.ntp.org iburst\n}) + expect(subject).to contain_file(conf_path).with('content' => %r{server \d.debian.pool.ntp.org iburst\n}) end when 'Suse' it 'uses the opensuse ntp servers' do - expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.opensuse.pool.ntp.org}) + expect(subject).to contain_file(conf_path).with('content' => %r{server \d.opensuse.pool.ntp.org}) end when 'FreeBSD' it 'uses the freebsd ntp servers' do - expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.freebsd.pool.ntp.org iburst maxpoll 9}) + expect(subject).to contain_file(conf_path).with('content' => %r{server \d.freebsd.pool.ntp.org iburst maxpoll 9}) end when 'Solaris' it 'uses the generic NTP pool servers' do @@ -156,7 +160,7 @@ end when 'AIX' it 'uses the generic NTP pool servers on AIX' do - expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.pool.ntp.org}) + expect(subject).to contain_file(conf_path).with('content' => %r{server \d.pool.ntp.org}) end else it {