summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG4
-rw-r--r--README.markdown6
-rw-r--r--manifests/config.pp1
-rw-r--r--manifests/init.pp1
-rw-r--r--manifests/params.pp6
-rw-r--r--spec/classes/ntp_config_spec.rb26
-rw-r--r--templates/ntp.conf.archlinux.erb6
-rw-r--r--templates/ntp.conf.debian.erb2
-rw-r--r--templates/ntp.conf.el.erb2
-rw-r--r--templates/ntp.conf.freebsd.erb5
-rw-r--r--templates/ntp.conf.gentoo.erb5
-rw-r--r--templates/ntp.conf.suse.erb6
12 files changed, 59 insertions, 11 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f567ad1..b176e46 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,7 +3,9 @@ Features:
- Completely refactored to split across several classes.
- rspec-puppet tests rewritten to cover more options.
- rspec-system tests added.
-- autoupdate deprecated in favor of directly setting package_ensure.
+- parameters in `ntp` class:
+ - `autoupdate`: deprecated in favor of directly setting package_ensure.
+ - `panic`: set to false if you wish to allow large clock skews.
2011-11-10 Dan Bode <dan@puppetlabs.com> - 0.0.4
Add Amazon Linux as a supported platform
diff --git a/README.markdown b/README.markdown
index a134838..c7b71e5 100644
--- a/README.markdown
+++ b/README.markdown
@@ -118,6 +118,12 @@ ntp package to be installed.
This determines the name of the package to install.
+####`panic`
+
+This determines if ntp should 'panic' in the event of a very large clock skew.
+We set this to false if you're on a virtual machine by default as they don't
+do a great job with keeping time.
+
####`restrict`
This sets the restrict options in the ntp configuration.
diff --git a/manifests/config.pp b/manifests/config.pp
index 80368f0..b34ef4f 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -1,6 +1,7 @@
class ntp::config(
$config = $ntp::config,
$config_template = $ntp::config_template,
+ $panic = $ntp::panic,
$restrict = $ntp::restrict,
$servers = $ntp::servers,
) inherits ntp {
diff --git a/manifests/init.pp b/manifests/init.pp
index 2dd9184..6d594c3 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -4,6 +4,7 @@ class ntp(
$config_template = $ntp::params::config_template,
$package_ensure = $ntp::params::package_ensure,
$package_name = $ntp::params::package_name,
+ $panic = $ntp::params::panic,
$restrict = $ntp::params::restrict,
$servers = $ntp::params::servers,
$service_enable = $ntp::params::service_enable,
diff --git a/manifests/params.pp b/manifests/params.pp
index 7903176..3486f6f 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -7,6 +7,12 @@ class ntp::params() {
$service_ensure = 'running'
$service_manage = true
+ # On virtual machines allow large clock skews.
+ $panic = $::is_virtual ? {
+ true => false,
+ default => true,
+ }
+
case $::osfamily {
'Debian': {
$config = '/etc/ntp.conf'
diff --git a/spec/classes/ntp_config_spec.rb b/spec/classes/ntp_config_spec.rb
index ddb9be9..80bee42 100644
--- a/spec/classes/ntp_config_spec.rb
+++ b/spec/classes/ntp_config_spec.rb
@@ -90,12 +90,12 @@ describe 'ntp::config' do
end
- describe "for virtual machines" do
+ describe 'for virtual machines' do
let(:params) {{}}
let(:facts) {{ :operatingsystem => 'Archlinux',
:osfamily => 'Linux',
- :isvirtual => 'false' }}
+ :is_virtual => true }}
it 'should not use local clock as a time source' do
content = param_value(subject, 'file', '/etc/ntp.conf', 'content')
@@ -104,6 +104,28 @@ describe 'ntp::config' do
'fudge 127.127.1.0 stratum 10' ]
(content.split("\n") & expected_lines).should_not == expected_lines
end
+
+ it 'allows large clock skews' do
+ content = param_value(subject, 'file', '/etc/ntp.conf', 'content')
+ expected_lines = [ 'tinker panic 0' ]
+ (content.split("\n") & expected_lines).should == expected_lines
+ end
+
+ end
+
+ describe 'for physical machines' do
+
+ let(:params) {{}}
+ let(:facts) {{ :operatingsystem => 'Archlinux',
+ :osfamily => 'Linux',
+ :is_virtual => false }}
+
+ it 'disallows large clock skews' do
+ content = param_value(subject, 'file', '/etc/ntp.conf', 'content')
+ expected_lines = [ 'tinker panic 0' ]
+ (content.split("\n") & expected_lines).should_not == expected_lines
+ end
+
end
describe "for operating system Archlinux" do
diff --git a/templates/ntp.conf.archlinux.erb b/templates/ntp.conf.archlinux.erb
index 22395d9..ef3b725 100644
--- a/templates/ntp.conf.archlinux.erb
+++ b/templates/ntp.conf.archlinux.erb
@@ -4,6 +4,12 @@
# - the ntp.conf man page
# - http://support.ntp.org/bin/view/Support/GettingStarted
# - https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon
+#
+<% if @panic == false -%>
+# Keep ntpd from panicking in the event of a large clock skew
+# # when a VM guest is suspended and resumed.
+tinker panic 0
+<% end -%>
# Associate to public NTP pool servers; see http://www.pool.ntp.org/
<% [@servers].flatten.each do |server| -%>
diff --git a/templates/ntp.conf.debian.erb b/templates/ntp.conf.debian.erb
index 7225fad..324b91c 100644
--- a/templates/ntp.conf.debian.erb
+++ b/templates/ntp.conf.debian.erb
@@ -1,6 +1,6 @@
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
-<% if @is_virtual == "true" -%>
+<% if @panic == false -%>
# Keep ntpd from panicking in the event of a large clock skew
# when a VM guest is suspended and resumed.
tinker panic 0
diff --git a/templates/ntp.conf.el.erb b/templates/ntp.conf.el.erb
index 4e90569..157b28d 100644
--- a/templates/ntp.conf.el.erb
+++ b/templates/ntp.conf.el.erb
@@ -1,4 +1,4 @@
-<% if @is_virtual == "true" -%>
+<% if @panic == false -%>
# Keep ntpd from panicking in the event of a large clock skew
# when a VM guest is suspended and resumed.
tinker panic 0
diff --git a/templates/ntp.conf.freebsd.erb b/templates/ntp.conf.freebsd.erb
index a55ba3d..7fcffb8 100644
--- a/templates/ntp.conf.freebsd.erb
+++ b/templates/ntp.conf.freebsd.erb
@@ -18,13 +18,12 @@
# The option `maxpoll 9' is used to prevent PLL/FLL flipping on FreeBSD.
#
# Managed by puppet class { "ntp": servers => [ ... ] }
-<% if @is_virtual == "true" -%>
-
+<% if @panic == false -%>
# Keep ntpd from panicking in the event of a large clock skew
# when a VM guest is suspended and resumed.
tinker panic 0
-
<% end -%>
+
<% [@servers].flatten.each do |server| -%>
server <%= server %>
<% end -%>
diff --git a/templates/ntp.conf.gentoo.erb b/templates/ntp.conf.gentoo.erb
index 7b00b46..c22026a 100644
--- a/templates/ntp.conf.gentoo.erb
+++ b/templates/ntp.conf.gentoo.erb
@@ -6,6 +6,11 @@
# Name of the servers ntpd should sync with
# Please respect the access policy as stated by the responsible person.
#server ntp.example.tld iburst
+<% if @panic == false -%>
+# Keep ntpd from panicking in the event of a large clock skew
+# # when a VM guest is suspended and resumed.
+tinker panic 0
+<% end -%>
# Managed by puppet class { "ntp": servers => [ ... ] }
<% [@servers].flatten.each do |server| -%>
diff --git a/templates/ntp.conf.suse.erb b/templates/ntp.conf.suse.erb
index e44e068..1cbe6a2 100644
--- a/templates/ntp.conf.suse.erb
+++ b/templates/ntp.conf.suse.erb
@@ -29,21 +29,21 @@
##
# server 127.127.8.0 mode 5 prefer
-<% if @is_virtual == "false" -%>
+<% if @panic == true -%>
##
## 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
-
<% end -%>
+
# Managed by puppet class { "ntp": servers => [ ... ] }
<% [@servers].flatten.each do |server| -%>
server <%= server %>
<% end -%>
-<% if @is_virtual == "true" -%>
+<% if @panic == false -%>
# Keep ntpd from panicking in the event of a large clock skew
# when a VM guest is suspended and resumed.
tinker panic 0