diff options
-rw-r--r-- | manifests/init.pp | 19 | ||||
-rw-r--r-- | spec/classes/ntp_spec.rb | 21 | ||||
-rw-r--r-- | templates/ntp.conf.suse.erb | 85 |
3 files changed, 121 insertions, 4 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index 67125d4..44e039b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -86,6 +86,21 @@ class ntp($servers='UNSET', $servers_real = $servers } } + SuSE: { + $supported = true + $pkg_name = [ 'ntp' ] + $svc_name = 'ntp' + $config = '/etc/ntp.conf' + $config_tpl = 'ntp.conf.suse.erb' + if ($servers == 'UNSET') { + $servers_real = [ '0.opensuse.pool.ntp.org', + '1.opensuse.pool.ntp.org', + '2.opensuse.pool.ntp.org', + '3.opensuse.pool.ntp.org', ] + } else { + $servers_real = $servers + } + } FreeBSD: { $supported = true $pkg_name = ['.*/net/ntp'] @@ -102,13 +117,13 @@ class ntp($servers='UNSET', } } default: { - fail("The ${module_name} module is not supported on ${::osfamily} based systems") + fail("The ${module_name} module is not supported on ${::osfamily} based systems") } } package { 'ntp': - name => $pkg_name, ensure => $package_ensure, + name => $pkg_name, } file { $config: diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb index 239f641..6ff453f 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -43,6 +43,23 @@ describe 'ntp' do end end + describe "for operating system family SuSE" do + + let(:params) {{}} + let(:facts) { { :osfamily => 'suse' } } + + it { should contain_service('ntp').with_name('ntp') } + it 'should use the redhat ntp servers by default' do + content = param_value(subject, 'file', '/etc/ntp.conf', 'content') + expected_lines = [ + 'server 0.opensuse.pool.ntp.org', + 'server 1.opensuse.pool.ntp.org', + 'server 2.opensuse.pool.ntp.org', + 'server 3.opensuse.pool.ntp.org'] + (content.split("\n") & expected_lines).should == expected_lines + end + end + describe "for operating system family FreeBSD" do let(:params) {{}} @@ -51,7 +68,7 @@ describe 'ntp' do it { should contain_service('ntp').with_name('ntpd') } it 'should use the freebsd ntp servers by default' do content = param_value(subject, 'file', '/etc/ntp.conf', 'content') - expected_lines = [ + expected_lines = [ "server 0.freebsd.pool.ntp.org iburst maxpoll 9", "server 1.freebsd.pool.ntp.org iburst maxpoll 9", "server 2.freebsd.pool.ntp.org iburst maxpoll 9", @@ -71,7 +88,7 @@ describe 'ntp' do end - ['Debian', 'RedHat', 'FreeBSD'].each do |osfamily| + ['Debian', 'RedHat','SuSE', 'FreeBSD'].each do |osfamily| describe "for operating system family #{osfamily}" do let(:facts) { { :osfamily => osfamily } } diff --git a/templates/ntp.conf.suse.erb b/templates/ntp.conf.suse.erb new file mode 100644 index 0000000..b25aac2 --- /dev/null +++ b/templates/ntp.conf.suse.erb @@ -0,0 +1,85 @@ +################################################################################ +## /etc/ntp.conf +## +## Sample NTP configuration file. +## See package 'ntp-doc' for documentation, Mini-HOWTO and FAQ. +## Copyright (c) 1998 S.u.S.E. GmbH Fuerth, Germany. +## +## Author: Michael Andres, <ma@suse.de> +## Michael Skibbe, <mskibbe@suse.de> +## +################################################################################ + +## +## Radio and modem clocks by convention have addresses in the +## form 127.127.t.u, where t is the clock type and u is a unit +## number in the range 0-3. +## +## Most of these clocks require support in the form of a +## serial port or special bus peripheral. The particular +## device is normally specified by adding a soft link +## /dev/device-u to the particular hardware device involved, +## where u correspond to the unit number above. +## +## Generic DCF77 clock on serial port (Conrad DCF77) +## Address: 127.127.8.u +## Serial Port: /dev/refclock-u +## +## (create soft link /dev/refclock-0 to the particular ttyS?) +## +# server 127.127.8.0 mode 5 prefer + +## +## Undisciplined Local Clock. This is a fake driver intended for backup +## and when no outside source of synchronized time is available. +## +server 127.127.1.0 # local clock (LCL) +fudge 127.127.1.0 stratum 10 # LCL is unsynchronized + +# Managed by puppet class { "ntp": servers => [ ... ] } +<% [servers_real].flatten.each do |server| -%> +server <%= server %> +<% end -%> + +<% if @is_virtual == "true" -%> +# Keep ntpd from panicking in the event of a large clock skew +# when a VM guest is suspended and resumed. +tinker panic 0 + +<% end -%> +## +## Miscellaneous stuff +## + +driftfile /var/lib/ntp/drift/ntp.drift # path for drift file + +logfile /var/log/ntp # alternate log file +# logconfig =syncstatus + sysevents +# logconfig =all + +# statsdir /tmp/ # directory for statistics files +# filegen peerstats file peerstats type day enable +# filegen loopstats file loopstats type day enable +# filegen clockstats file clockstats type day enable + +<% if @restrict -%> +# Permit time synchronization with our time source, but do not +# permit the source to query or modify the service on this system. +restrict -4 default kod nomodify notrap nopeer noquery +restrict -6 default kod nomodify notrap nopeer noquery + +# Permit all access over the loopback interface. This could +# be tightened as well, but to do so would effect some of +# the administrative functions. +restrict 127.0.0.1 +restrict -6 ::1 + +<% end -%> + +# +# Authentication stuff +# +keys /etc/ntp.keys # path for keys file +trustedkey 1 # define trusted keys +requestkey 1 # key (7) for accessing server variables +# controlkey 15 # key (6) for accessing server variables |