Skip to content

Commit 12ff9af

Browse files
committed
add SuSE support
1 parent 63cc300 commit 12ff9af

File tree

3 files changed

+121
-4
lines changed

3 files changed

+121
-4
lines changed

manifests/init.pp

+17-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@
8686
$servers_real = $servers
8787
}
8888
}
89+
SuSE: {
90+
$supported = true
91+
$pkg_name = [ 'ntp' ]
92+
$svc_name = 'ntp'
93+
$config = '/etc/ntp.conf'
94+
$config_tpl = 'ntp.conf.suse.erb'
95+
if ($servers == 'UNSET') {
96+
$servers_real = [ '0.opensuse.pool.ntp.org',
97+
'1.opensuse.pool.ntp.org',
98+
'2.opensuse.pool.ntp.org',
99+
'3.opensuse.pool.ntp.org', ]
100+
} else {
101+
$servers_real = $servers
102+
}
103+
}
89104
FreeBSD: {
90105
$supported = true
91106
$pkg_name = ['.*/net/ntp']
@@ -102,13 +117,13 @@
102117
}
103118
}
104119
default: {
105-
fail("The ${module_name} module is not supported on ${::osfamily} based systems")
120+
fail("The ${module_name} module is not supported on ${::osfamily} based systems")
106121
}
107122
}
108123

109124
package { 'ntp':
110-
name => $pkg_name,
111125
ensure => $package_ensure,
126+
name => $pkg_name,
112127
}
113128

114129
file { $config:

spec/classes/ntp_spec.rb

+19-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ def param_value(subject, type, title, param)
4343
end
4444
end
4545

46+
describe "for operating system family SuSE" do
47+
48+
let(:params) {{}}
49+
let(:facts) { { :osfamily => 'suse' } }
50+
51+
it { should contain_service('ntp').with_name('ntp') }
52+
it 'should use the redhat ntp servers by default' do
53+
content = param_value(subject, 'file', '/etc/ntp.conf', 'content')
54+
expected_lines = [
55+
'server 0.opensuse.pool.ntp.org',
56+
'server 1.opensuse.pool.ntp.org',
57+
'server 2.opensuse.pool.ntp.org',
58+
'server 3.opensuse.pool.ntp.org']
59+
(content.split("\n") & expected_lines).should == expected_lines
60+
end
61+
end
62+
4663
describe "for operating system family FreeBSD" do
4764

4865
let(:params) {{}}
@@ -51,7 +68,7 @@ def param_value(subject, type, title, param)
5168
it { should contain_service('ntp').with_name('ntpd') }
5269
it 'should use the freebsd ntp servers by default' do
5370
content = param_value(subject, 'file', '/etc/ntp.conf', 'content')
54-
expected_lines = [
71+
expected_lines = [
5572
"server 0.freebsd.pool.ntp.org iburst maxpoll 9",
5673
"server 1.freebsd.pool.ntp.org iburst maxpoll 9",
5774
"server 2.freebsd.pool.ntp.org iburst maxpoll 9",
@@ -71,7 +88,7 @@ def param_value(subject, type, title, param)
7188

7289
end
7390

74-
['Debian', 'RedHat', 'FreeBSD'].each do |osfamily|
91+
['Debian', 'RedHat','SuSE', 'FreeBSD'].each do |osfamily|
7592
describe "for operating system family #{osfamily}" do
7693

7794
let(:facts) { { :osfamily => osfamily } }

templates/ntp.conf.suse.erb

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
################################################################################
2+
## /etc/ntp.conf
3+
##
4+
## Sample NTP configuration file.
5+
## See package 'ntp-doc' for documentation, Mini-HOWTO and FAQ.
6+
## Copyright (c) 1998 S.u.S.E. GmbH Fuerth, Germany.
7+
##
8+
## Author: Michael Andres, <ma@suse.de>
9+
## Michael Skibbe, <mskibbe@suse.de>
10+
##
11+
################################################################################
12+
13+
##
14+
## Radio and modem clocks by convention have addresses in the
15+
## form 127.127.t.u, where t is the clock type and u is a unit
16+
## number in the range 0-3.
17+
##
18+
## Most of these clocks require support in the form of a
19+
## serial port or special bus peripheral. The particular
20+
## device is normally specified by adding a soft link
21+
## /dev/device-u to the particular hardware device involved,
22+
## where u correspond to the unit number above.
23+
##
24+
## Generic DCF77 clock on serial port (Conrad DCF77)
25+
## Address: 127.127.8.u
26+
## Serial Port: /dev/refclock-u
27+
##
28+
## (create soft link /dev/refclock-0 to the particular ttyS?)
29+
##
30+
# server 127.127.8.0 mode 5 prefer
31+
32+
##
33+
## Undisciplined Local Clock. This is a fake driver intended for backup
34+
## and when no outside source of synchronized time is available.
35+
##
36+
server 127.127.1.0 # local clock (LCL)
37+
fudge 127.127.1.0 stratum 10 # LCL is unsynchronized
38+
39+
# Managed by puppet class { "ntp": servers => [ ... ] }
40+
<% [servers_real].flatten.each do |server| -%>
41+
server <%= server %>
42+
<% end -%>
43+
44+
<% if @is_virtual == "true" -%>
45+
# Keep ntpd from panicking in the event of a large clock skew
46+
# when a VM guest is suspended and resumed.
47+
tinker panic 0
48+
49+
<% end -%>
50+
##
51+
## Miscellaneous stuff
52+
##
53+
54+
driftfile /var/lib/ntp/drift/ntp.drift # path for drift file
55+
56+
logfile /var/log/ntp # alternate log file
57+
# logconfig =syncstatus + sysevents
58+
# logconfig =all
59+
60+
# statsdir /tmp/ # directory for statistics files
61+
# filegen peerstats file peerstats type day enable
62+
# filegen loopstats file loopstats type day enable
63+
# filegen clockstats file clockstats type day enable
64+
65+
<% if @restrict -%>
66+
# Permit time synchronization with our time source, but do not
67+
# permit the source to query or modify the service on this system.
68+
restrict -4 default kod nomodify notrap nopeer noquery
69+
restrict -6 default kod nomodify notrap nopeer noquery
70+
71+
# Permit all access over the loopback interface. This could
72+
# be tightened as well, but to do so would effect some of
73+
# the administrative functions.
74+
restrict 127.0.0.1
75+
restrict -6 ::1
76+
77+
<% end -%>
78+
79+
#
80+
# Authentication stuff
81+
#
82+
keys /etc/ntp.keys # path for keys file
83+
trustedkey 1 # define trusted keys
84+
requestkey 1 # key (7) for accessing server variables
85+
# controlkey 15 # key (6) for accessing server variables

0 commit comments

Comments
 (0)