summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Fridh <frimik@gmail.com>2013-02-23 01:17:54 +0100
committerMikael Fridh <mfridh@marinsoftware.com>2013-02-23 01:20:34 +0100
commit0569bb6388b35e79bee9142e832347272b4bfe16 (patch)
tree8446f02c618497b81957ab627c0c395617c36769
parente1c8433552ce7044541843b019aa3069a45c10d1 (diff)
ntp: fixes #19418 - allow template override
This allows a template to be explicitly set.
-rw-r--r--README.markdown4
-rw-r--r--manifests/init.pp12
-rw-r--r--spec/classes/ntp_spec.rb6
3 files changed, 21 insertions, 1 deletions
diff --git a/README.markdown b/README.markdown
index 6cfa7c8..3a84185 100644
--- a/README.markdown
+++ b/README.markdown
@@ -71,6 +71,10 @@ This parameter is used to determine whether the ntp package will be updated auto
This parameter allows you to choose whether to automatically start ntp daemon on boot.
+####`template`
+
+This parameter allows you to explicitly override the template used.
+
Limitations
------------
diff --git a/manifests/init.pp b/manifests/init.pp
index 543db63..08296b7 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -27,6 +27,9 @@
# $enable = true
# Automatically start ntp deamon on boot.
#
+# $template = '${module_name}/${config_tpl}'
+# Override with your own explicit template.
+#
# Actions:
#
# Installs, configures, and manages the ntp service.
@@ -45,6 +48,7 @@ class ntp($servers='UNSET',
$ensure='running',
$enable=true,
$restrict=true,
+ $config_template=undef,
$autoupdate=false
) {
@@ -125,6 +129,12 @@ class ntp($servers='UNSET',
}
}
+ if ($config_template == undef) {
+ $template_real = "${module_name}/${config_tpl}"
+ } else {
+ $template_real = $config_template
+ }
+
package { 'ntp':
ensure => $package_ensure,
name => $pkg_name,
@@ -135,7 +145,7 @@ class ntp($servers='UNSET',
owner => 0,
group => 0,
mode => '0644',
- content => template("${module_name}/${config_tpl}"),
+ content => template($template_real),
require => Package[$pkg_name],
}
diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb
index 8f41a22..8561171 100644
--- a/spec/classes/ntp_spec.rb
+++ b/spec/classes/ntp_spec.rb
@@ -108,6 +108,12 @@ describe 'ntp' do
params[:autoupdate] = true
subject.should contain_package('ntp').with_ensure('latest')
end
+ it 'should allow template to be overridden' do
+ params[:config_template] = 'my_ntp/ntp.conf.my'
+ content = param_value(subject, 'file', '/etc/ntp.conf', 'content')
+ expected_lines = ['server foobar']
+ (content.split("\n") & expected_lines).should == expected_lines
+ end
end
end
end