diff options
-rw-r--r-- | manifests/init.pp | 47 | ||||
-rw-r--r-- | spec/classes/ntp_spec.rb | 13 |
2 files changed, 31 insertions, 29 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index b404071..74dcc5f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -51,7 +51,6 @@ class ntp($servers='UNSET', case $::operatingsystem { debian, ubuntu: { - $supported = true $pkg_name = [ 'ntp' ] $svc_name = 'ntp' $config = '/etc/ntp.conf' @@ -66,7 +65,6 @@ class ntp($servers='UNSET', } } centos, redhat, oel, linux, fedora, Amazon: { - $supported = true $pkg_name = [ 'ntp' ] $svc_name = 'ntpd' $config = '/etc/ntp.conf' @@ -80,7 +78,6 @@ class ntp($servers='UNSET', } } freebsd: { - $supported = true $pkg_name = ['.*/net/ntp'] $svc_name = 'ntpd' $config = '/etc/ntp.conf' @@ -95,35 +92,29 @@ class ntp($servers='UNSET', } } default: { - $supported = false - notify { "${module_name}_unsupported": - message => "The ${module_name} module is not supported on ${::operatingsystem}", - } + fail("The ${module_name} module is not supported on ${::operatingsystem}") } } - if ($supported == true) { - - package { 'ntp': - ensure => $package_ensure, - name => $pkg_name, - } + package { 'ntp': + name => $pkg_name, + ensure => $package_ensure, + } - file { $config: - ensure => file, - owner => 0, - group => 0, - mode => '0644', - content => template("${module_name}/${config_tpl}"), - require => Package[$pkg_name], - } + file { $config: + ensure => file, + owner => 0, + group => 0, + mode => '0644', + content => template("${module_name}/${config_tpl}"), + require => Package[$pkg_name], + } - service { 'ntp': - ensure => $ensure, - name => $svc_name, - hasstatus => true, - hasrestart => true, - subscribe => [ Package[$pkg_name], File[$config] ], - } + service { 'ntp': + ensure => $ensure, + name => $svc_name, + hasstatus => true, + hasrestart => true, + subscribe => [ Package[$pkg_name], File[$config] ], } } diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb index ac68b89..389f085 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -60,7 +60,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", @@ -68,6 +68,17 @@ describe 'ntp' do (content.split("\n") & expected_lines).should == expected_lines end end + + describe "for operating system unsupported" do + let(:facts) {{ + :operatingsystem => 'unsupported', + }} + + it { expect{ subject }.to raise_error( + /^The ntp module is not supported on unsupported/ + )} + end + end (redhatish + debianish + bsdish).each do |os| |