summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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