Skip to content

Commit 6caa34e

Browse files
Add support for Ubuntu 24.04
- Use ntpsec package on Debian 12 and Ubuntu 24.04. - Set '/etc/default/ntpsec' as daemon_config path for ntpsec platforms. - Adjust specs for Ubuntu 24.04 tests. Co-authored-by: Kjetil Torgrim Homme <[email protected]>
1 parent fa8305c commit 6caa34e

File tree

8 files changed

+48
-20
lines changed

8 files changed

+48
-20
lines changed

data/Debian-12.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
ntp::package_name:
3+
- ntpsec
4+
ntp::config: '/etc/ntpsec/ntp.conf'

data/Ubuntu-24.04.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
ntp::package_name:
3+
- ntpsec
4+
ntp::config: '/etc/ntpsec/ntp.conf'

manifests/config.pp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,22 @@
3333
}
3434
}
3535
'Debian': {
36-
if $facts['os']['release']['major'] == '12' {
37-
$daemon_config = '/etc/ntpsec/ntp.conf'
36+
if $facts['os']['name'] == 'Ubuntu' {
37+
# This ugly indentation is forced upon me by puppet-lint. I disclaim
38+
# any responsibility for damage to your eyes.
39+
if (versioncmp($facts['os']['release']['major'], '18.04') >= 0 and
40+
versioncmp($facts['os']['release']['major'], '24.04') < 0 and
41+
$ntp::user) {
42+
file_line { 'Set NTPD daemon user':
43+
ensure => present,
44+
path => '/usr/lib/ntp/ntp-systemd-wrapper',
45+
line => "RUNASUSER=${ntp::user}",
46+
match => '^RUNASUSER\=',
47+
}
48+
}
49+
}
50+
if 'ntpsec' in $ntp::package_name {
51+
$daemon_config = '/etc/default/ntpsec'
3852
} else {
3953
$daemon_config = '/etc/default/ntp'
4054
}
@@ -46,14 +60,6 @@
4660
match => '^NTPD_OPTS\=',
4761
}
4862
}
49-
if $ntp::user and $facts['os']['release']['major'] == '18.04' {
50-
file_line { 'Set NTPD daemon user':
51-
ensure => present,
52-
path => '/usr/lib/ntp/ntp-systemd-wrapper',
53-
line => "RUNASUSER=${ntp::user}",
54-
match => '^RUNASUSER\=',
55-
}
56-
}
5763
}
5864
'Suse': {
5965
$daemon_config = '/etc/sysconfig/ntp'

metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
"operatingsystemrelease": [
5959
"18.04",
6060
"20.04",
61-
"22.04"
61+
"22.04",
62+
"24.04"
6263
]
6364
},
6465
{

spec/acceptance/ntp_parameters_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
config = if os[:family] == 'solaris'
2626
'/etc/inet/ntp.conf'
27+
elsif os[:family] == 'ubuntu' && os[:release].start_with?('24')
28+
'/etc/ntpsec/ntp.conf'
2729
else
2830
'/etc/ntp.conf'
2931
end

spec/acceptance/ntp_user_and_daemon_opts_spec.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,26 @@
2929
'/etc/sysconfig/ntp'
3030
elsif os[:family] == 'debian' && os[:release].start_with?('12')
3131
'/etc/ntpsec/ntp.conf'
32+
elsif os[:family] == 'ubuntu' && os[:release].start_with?('24')
33+
'/etc/default/ntpsec'
3234
else
3335
'/etc/default/ntp'
3436
end
3537

36-
if os[:family] == 'debian' && os[:release].start_with?('12')
38+
if os[:family] == 'debian' && os[:release].to_i >= 12
3739
ntpd_opts_match = %r{(OPTIONS|NTPD_OPTS)='-g -i /var/lib/ntpsec'}
38-
chroot_dir = '/var/lib/ntpsec'
40+
chroot_opt = '-i /var/lib/ntpsec'
41+
elsif os[:family] == 'ubuntu' && os[:release].to_f >= 24.04
42+
ntpd_opts_match = %r{(OPTIONS|NTPD_OPTS)='-g '}
43+
chroot_opt = ''
3944
else
4045
ntpd_opts_match = %r{(OPTIONS|NTPD_OPTS)='-g -i /var/lib/ntp'}
41-
chroot_dir = '/var/lib/ntp'
46+
chroot_opt = '-i /var/lib/ntp'
4247
end
4348

4449
describe 'ntp class with daemon options:', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) || (os[:release].start_with?('5') && os[:family] == 'redhat') do
4550
let(:pp) do
46-
"class { 'ntp': service_enable => true, service_ensure => running, service_manage => true, service_name => '#{servicename}', user => 'ntp', daemon_extra_opts => '-g -i #{chroot_dir}' }"
51+
"class { 'ntp': service_enable => true, service_ensure => running, service_manage => true, service_name => '#{servicename}', user => 'ntp', daemon_extra_opts => '-g #{chroot_opt}' }"
4752
end
4853

4954
context 'when run' do

spec/acceptance/preferred_servers_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
config = if os[:family] == 'solaris'
66
'/etc/inet/ntp.conf'
7+
elsif os[:family] == 'ubuntu' && os[:release].start_with?('24')
8+
'/etc/ntpsec/ntp.conf'
79
else
810
'/etc/ntp.conf'
911
end

spec/classes/ntp_spec.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
let(:conf_path) do
1010
if os.include?('solaris')
1111
'/etc/inet/ntp.conf'
12+
elsif f[:os]['name'] == 'Debian' && f[:os]['release']['major'].to_f >= 12
13+
'/etc/ntpsec/ntp.conf'
14+
elsif f[:os]['name'] == 'Ubuntu' && f[:os]['release']['major'].to_f >= 24.04
15+
'/etc/ntpsec/ntp.conf'
1216
else
1317
'/etc/ntp.conf'
1418
end
@@ -132,31 +136,31 @@
132136
case f[:os]['family']
133137
when 'RedHat'
134138
it 'uses the centos ntp servers' do
135-
expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.centos.pool.ntp.org})
139+
expect(subject).to contain_file(conf_path).with('content' => %r{server \d.centos.pool.ntp.org})
136140
end
137141

138142
it do
139143
expect(subject).to contain_file('/etc/ntp/step-tickers').with('content' => %r{\d.centos.pool.ntp.org})
140144
end
141145
when 'Debian'
142146
it 'uses the debian ntp servers' do
143-
expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.debian.pool.ntp.org iburst\n})
147+
expect(subject).to contain_file(conf_path).with('content' => %r{server \d.debian.pool.ntp.org iburst\n})
144148
end
145149
when 'Suse'
146150
it 'uses the opensuse ntp servers' do
147-
expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.opensuse.pool.ntp.org})
151+
expect(subject).to contain_file(conf_path).with('content' => %r{server \d.opensuse.pool.ntp.org})
148152
end
149153
when 'FreeBSD'
150154
it 'uses the freebsd ntp servers' do
151-
expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.freebsd.pool.ntp.org iburst maxpoll 9})
155+
expect(subject).to contain_file(conf_path).with('content' => %r{server \d.freebsd.pool.ntp.org iburst maxpoll 9})
152156
end
153157
when 'Solaris'
154158
it 'uses the generic NTP pool servers' do
155159
expect(subject).to contain_file('/etc/inet/ntp.conf').with('content' => %r{server \d.pool.ntp.org})
156160
end
157161
when 'AIX'
158162
it 'uses the generic NTP pool servers on AIX' do
159-
expect(subject).to contain_file('/etc/ntp.conf').with('content' => %r{server \d.pool.ntp.org})
163+
expect(subject).to contain_file(conf_path).with('content' => %r{server \d.pool.ntp.org})
160164
end
161165
else
162166
it {

0 commit comments

Comments
 (0)