Skip to content

Commit 55a3166

Browse files
author
Helen Campbell
committed
Work for SLES 12 compatibility
1 parent 9937d96 commit 55a3166

File tree

6 files changed

+43
-14
lines changed

6 files changed

+43
-14
lines changed

README.markdown

+4
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ Tells Puppet whether to manage the NTP service. Valid options: 'true' or 'false'
302302

303303
Tells Puppet what NTP service to manage. Valid options: string. Default value: varies by operating system
304304

305+
####`service_provider`
306+
307+
Tells Puppet which service provider to use for NTP. Valid options: string. Default value: 'undef'
308+
305309
####`stepout`
306310

307311
Tells puppet to change stepout. Applies only if `tinker` value is 'true'. Valid options: unsigned shortint digit. Default value: undef.

manifests/config.pp

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Private Class
22
class ntp::config inherits ntp {
33

4+
#The servers-netconfig file overrides NTP config on SLES 12, interfering with our configuration.
5+
if $::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '12' {
6+
file { '/var/run/ntp/servers-netconfig':
7+
ensure => 'absent'
8+
}
9+
}
10+
411
if $ntp::keys_enable {
512
case $ntp::config_dir {
613
'/', '/etc', undef: {}

manifests/init.pp

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
$service_ensure = $ntp::params::service_ensure,
3535
$service_manage = $ntp::params::service_manage,
3636
$service_name = $ntp::params::service_name,
37+
$service_provider = $ntp::params::service_provider,
3738
$stepout = $ntp::params::stepout,
3839
$tinker = $ntp::params::tinker,
3940
$tos = $ntp::params::tos,

manifests/params.pp

+15
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
'3.debian.pool.ntp.org',
7878
]
7979
$maxpoll = undef
80+
$service_provider= undef
8081
}
8182
'Debian': {
8283
$config = $default_config
@@ -98,6 +99,7 @@
9899
'3.debian.pool.ntp.org',
99100
]
100101
$maxpoll = undef
102+
$service_provider= undef
101103
}
102104
'RedHat': {
103105
$config = $default_config
@@ -106,6 +108,7 @@
106108
$package_name = $default_package_name
107109
$service_name = $default_service_name
108110
$maxpoll = undef
111+
$service_provider= undef
109112

110113
case $::operatingsystem {
111114
'Fedora': {
@@ -146,23 +149,28 @@
146149
$service_name = 'ntp'
147150
$keys_file = '/etc/ntp.keys'
148151
$package_name = [ 'xntp' ]
152+
$service_provider = undef
149153
}
150154
'11': {
151155
$service_name = 'ntp'
152156
$keys_file = $default_keys_file
153157
$package_name = $default_package_name
158+
$service_provider = undef
154159
}
155160
'12': {
156161
$service_name = 'ntpd'
157162
$keys_file = '/etc/ntp.keys'
158163
$package_name = $default_package_name
164+
#Puppet 3 does not recognise systemd as service provider on SLES 12.
165+
$service_provider = 'systemd'
159166
}
160167
default: {
161168
fail("The ${module_name} module is not supported on an ${::operatingsystem} ${::operatingsystemmajrelease} distribution.")
162169
}
163170
}
164171
}
165172
'OpenSuSE': {
173+
$service_provider = undef
166174
case $::operatingsystemrelease {
167175
'13.2': {
168176
$service_name = 'ntpd'
@@ -180,6 +188,7 @@
180188
$service_name = 'ntp'
181189
$keys_file = $default_keys_file
182190
$package_name = $default_package_name
191+
$service_provider = undef
183192
}
184193
}
185194
$config = $default_config
@@ -219,6 +228,7 @@
219228
'3.freebsd.pool.ntp.org',
220229
]
221230
$maxpoll = 9
231+
$service_provider= undef
222232
}
223233
'Archlinux': {
224234
$config = $default_config
@@ -240,6 +250,7 @@
240250
'3.arch.pool.ntp.org',
241251
]
242252
$maxpoll = undef
253+
$service_provider= undef
243254
}
244255
'Solaris': {
245256
$config = '/etc/inet/ntp.conf'
@@ -272,6 +283,7 @@
272283
'3.pool.ntp.org',
273284
]
274285
$maxpoll = undef
286+
$service_provider= undef
275287
}
276288
# Gentoo was added as its own $::osfamily in Facter 1.7.0
277289
'Gentoo': {
@@ -294,6 +306,7 @@
294306
'3.gentoo.pool.ntp.org',
295307
]
296308
$maxpoll = undef
309+
$service_provider= undef
297310
}
298311
'Linux': {
299312
# Account for distributions that don't have $::osfamily specific settings.
@@ -319,6 +332,7 @@
319332
'3.gentoo.pool.ntp.org',
320333
]
321334
$maxpoll = undef
335+
$service_provider= undef
322336
}
323337
'Amazon': {
324338
$config = $default_config
@@ -339,6 +353,7 @@
339353
'2.centos.pool.ntp.org',
340354
]
341355
$maxpoll = undef
356+
$service_provider= undef
342357
$disable_monitor = false
343358
}
344359
default: {

manifests/service.pp

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
ensure => $ntp::service_ensure,
1111
enable => $ntp::service_enable,
1212
name => $ntp::service_name,
13+
provider => $ntp::service_provider,
1314
hasstatus => true,
1415
hasrestart => true,
1516
}

spec/classes/ntp_spec.rb

+15-14
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@
33
describe 'ntp' do
44
let(:facts) {{ :is_virtual => 'false' }}
55

6-
['Debian', 'RedHat', 'Fedora', 'Suse', 'FreeBSD', 'Archlinux', 'Gentoo', 'Gentoo (Facter < 1.7)'].each do |system|
6+
['Debian', 'RedHat', 'Fedora', 'Suse11', 'Suse12', 'FreeBSD', 'Archlinux', 'Gentoo', 'Gentoo (Facter < 1.7)'].each do |system|
77
context "when on system #{system}" do
8-
if system == 'Gentoo (Facter < 1.7)'
9-
let :facts do
8+
let :facts do
9+
case system
10+
when 'Gentoo (Facter < 1.7)'
1011
super().merge({ :osfamily => 'Linux', :operatingsystem => 'Gentoo' })
11-
end
12-
elsif system == 'Suse'
13-
let :facts do
14-
super().merge({ :osfamily => system,:operatingsystem => 'SLES',:operatingsystemmajrelease => '11' })
15-
end
16-
elsif system == 'Fedora'
17-
let :facts do
18-
super().merge({ :osfamily => 'RedHat', :operatingsystem => system ,:operatingsystemmajrelease => '22' })
19-
end
20-
else
21-
let :facts do
12+
when 'Suse11'
13+
super().merge({ :osfamily => 'Suse', :operatingsystem => 'SLES', :operatingsystemmajrelease => '11' })
14+
when 'Suse12'
15+
super().merge({ :osfamily => 'Suse', :operatingsystem => 'SLES', :operatingsystemmajrelease => '12' })
16+
when 'Fedora'
17+
super().merge({ :osfamily => 'RedHat', :operatingsystem => system, :operatingsystemmajrelease => '22' })
18+
else
2219
super().merge({ :osfamily => system })
2320
end
2421
end
@@ -32,6 +29,10 @@
3229
it { should contain_file('/etc/ntp.conf').with_group('0') }
3330
it { should contain_file('/etc/ntp.conf').with_mode('0644') }
3431

32+
if system == 'Suse12'
33+
it { should contain_file('/var/run/ntp/servers-netconfig').with_ensure_absent }
34+
end
35+
3536
describe 'allows template to be overridden' do
3637
let(:params) {{ :config_template => 'my_ntp/ntp.conf.erb' }}
3738
it { should contain_file('/etc/ntp.conf').with({

0 commit comments

Comments
 (0)