From 5d06123df9aeb4c104843827afd855d9781aa914 Mon Sep 17 00:00:00 2001 From: Bill Weiss Date: Sun, 4 Nov 2012 17:44:23 -0600 Subject: Trivial fix for style, and made the README and comment match up Puppet-lint was complaining about "ensure found on line but it's not the first attribute on line 109". Trivial fix (swapped the ensure and the name). Also, the README didn't mention Debian or CentOS, but the comment block in init.pp did. I added both to the README. I happen to be using this with Debian unstable, but I haven't tested it extensively enough to say "yep, this works". It, however, works for me. --- README.markdown | 3 ++- manifests/init.pp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index bc6476a..a1e168a 100644 --- a/README.markdown +++ b/README.markdown @@ -6,7 +6,8 @@ This module has been built and tested using Puppet 2.6.x # Platforms # - * Enterprise Linux 5 + * Enterprise Linux 5 (and CentOS 5.4) * Ubuntu 10.04 Lucid * Amazon Linux 2011.09 has been tested on 2.7.x with facter version 1.6.2 * FreeBSD 9.0 + * Debian 6.0 Squeeze diff --git a/manifests/init.pp b/manifests/init.pp index 21f4296..b404071 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -105,8 +105,8 @@ class ntp($servers='UNSET', if ($supported == true) { package { 'ntp': - name => $pkg_name, ensure => $package_ensure, + name => $pkg_name, } file { $config: -- cgit v1.2.3 From 89e8d1e3a6311a73409fe9fd4a9594bbf5a166ef Mon Sep 17 00:00:00 2001 From: stephen Date: Tue, 16 Oct 2012 12:48:29 +0100 Subject: have the module fail on unsupported os --- manifests/init.pp | 11 +---------- spec/classes/ntp_spec.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b404071..0d19747 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,15 +92,10 @@ 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, @@ -125,5 +117,4 @@ class ntp($servers='UNSET', 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| -- cgit v1.2.3 From d218ce04872aeec45cfd0398824acf20e728aa18 Mon Sep 17 00:00:00 2001 From: stephen Date: Mon, 22 Oct 2012 10:41:45 +0100 Subject: Fix indentation --- manifests/init.pp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 0d19747..74dcc5f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -96,25 +96,25 @@ class ntp($servers='UNSET', } } - 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] ], + } } -- cgit v1.2.3 From 4b9a9e6f1288a4a98353d979aa92766ab27005d8 Mon Sep 17 00:00:00 2001 From: Tony Bussieres Date: Mon, 19 Nov 2012 13:46:43 -0500 Subject: added the enable parameter to the init class, so that one can configure ntp to start on boot. --- manifests/init.pp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 74dcc5f..e8a4c34 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -34,6 +34,7 @@ # [Remember: No empty lines between comments and class definition] class ntp($servers='UNSET', $ensure='running', + $enable='true', $autoupdate=false ) { @@ -110,11 +111,13 @@ class ntp($servers='UNSET', 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, + enable => $enable, + name => $svc_name, + hasstatus => true, + hasrestart => true, + subscribe => [ Package[$pkg_name], File[$config] ], + } } } -- cgit v1.2.3 From bd2a757b852a339fb22492598f39841825e6b12c Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 28 Nov 2012 11:40:01 -0500 Subject: Add restrict parameter NTP servers should not restrict themselves to 127.0.0.1, and this commit adds a `restrict` parameter to enable/disable this configuration block in the relevent templates. --- manifests/init.pp | 7 +++++++ templates/ntp.conf.debian.erb | 2 ++ templates/ntp.conf.el.erb | 2 ++ 3 files changed, 11 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index e8a4c34..6f4cc8b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -18,6 +18,12 @@ # '2.debian.pool.ntp.org iburst', # '3.debian.pool.ntp.org iburst', ] # +# $restrict = true +# Whether to restrict ntp daemons from allowing others to use as a server. +# +# $autoupdate = false +# Whether to update the ntp package automatically or not. +# # Actions: # # Installs, configures, and manages the ntp service. @@ -35,6 +41,7 @@ class ntp($servers='UNSET', $ensure='running', $enable='true', + $restrict=true, $autoupdate=false ) { diff --git a/templates/ntp.conf.debian.erb b/templates/ntp.conf.debian.erb index 7a3f690..5d966f8 100644 --- a/templates/ntp.conf.debian.erb +++ b/templates/ntp.conf.debian.erb @@ -30,6 +30,7 @@ filegen clockstats file clockstats type day enable server <%= server %> <% end -%> +<% if @restrict -%> # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page # might also be helpful. @@ -50,6 +51,7 @@ restrict ::1 # cryptographically authenticated. #restrict 192.168.123.0 mask 255.255.255.0 notrust +<% end -%> # If you want to provide time to your local subnet, change the next line. # (Again, the address is an example only.) diff --git a/templates/ntp.conf.el.erb b/templates/ntp.conf.el.erb index fe8a9a5..80b358b 100644 --- a/templates/ntp.conf.el.erb +++ b/templates/ntp.conf.el.erb @@ -4,6 +4,7 @@ tinker panic 0 <% end -%> +<% 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 default kod nomodify notrap nopeer noquery @@ -18,6 +19,7 @@ restrict -6 ::1 # Hosts on local network are less restricted. #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap +<% end -%> # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). -- cgit v1.2.3 From ca1e5a76698970264c223d743a08d9765866bb74 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Mon, 10 Dec 2012 10:09:15 -0800 Subject: Increment Modulefile for 0.2.0 release 0.2.0 is a backwards compatible feature and bug-fix release. Since 0.1.0, support for Amazon Linux was added, fixes for style were implemented and support was added for tinker_panic. tinker_panic will default to on when the fact is_virtual is true. --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index e73a6ca..d9e2f1a 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-ntp' -version '0.1.0' +version '0.2.0' source 'git://github.com/puppetlabs/puppetlabs-ntp' author 'Puppet Labs' license 'Apache Version 2.0' -- cgit v1.2.3 From 78fdcf83c84fb35d689cfcf8ab560bad88ea74d0 Mon Sep 17 00:00:00 2001 From: Tony Bussieres Date: Mon, 10 Dec 2012 15:06:46 -0500 Subject: Fix service indentation, added parameter documentation --- manifests/init.pp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 6f4cc8b..29358bd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -24,6 +24,9 @@ # $autoupdate = false # Whether to update the ntp package automatically or not. # +# $enable = true +# Automatically start ntp deamon on boot. +# # Actions: # # Installs, configures, and manages the ntp service. @@ -40,7 +43,7 @@ # [Remember: No empty lines between comments and class definition] class ntp($servers='UNSET', $ensure='running', - $enable='true', + $enable=true, $restrict=true, $autoupdate=false ) { @@ -118,13 +121,12 @@ class ntp($servers='UNSET', require => Package[$pkg_name], } - service { 'ntp': - ensure => $ensure, - enable => $enable, - name => $svc_name, - hasstatus => true, - hasrestart => true, - subscribe => [ Package[$pkg_name], File[$config] ], - } + service { 'ntp': + ensure => $ensure, + enable => $enable, + name => $svc_name, + hasstatus => true, + hasrestart => true, + subscribe => [ Package[$pkg_name], File[$config] ], } } -- cgit v1.2.3