diff options
author | Adrien Thebo <git@somethingsinistral.net> | 2013-03-08 09:19:59 -0800 |
---|---|---|
committer | Adrien Thebo <git@somethingsinistral.net> | 2013-03-08 09:19:59 -0800 |
commit | b1b3132f84d1628800e50a65f6c49bb998872acc (patch) | |
tree | 4e55fbfaa5407c1019418d9e3913718c65bd241d | |
parent | fd064cbdf39bf12794e4c6733b188a077a47a214 (diff) | |
parent | 9968350db2343272068601bf5709c2548bc73eb7 (diff) |
Merge pull request #47 from frimik/feature-19418-ntp-template
ntp: fixes #19418 - allow template override
-rw-r--r-- | README.markdown | 4 | ||||
-rw-r--r-- | manifests/init.pp | 12 | ||||
-rw-r--r-- | spec/classes/ntp_spec.rb | 6 | ||||
-rw-r--r-- | spec/fixtures/modules/my_ntp/templates/ntp.conf.erb | 4 |
4 files changed, 25 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 9b9c465..af1f8d5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -28,6 +28,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. @@ -46,6 +49,7 @@ class ntp($servers='UNSET', $ensure='running', $enable=true, $restrict=true, + $config_template=undef, $autoupdate=false ) { @@ -147,6 +151,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, @@ -157,7 +167,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 e74f7c1..9ce690b 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -128,6 +128,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.erb' + 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 diff --git a/spec/fixtures/modules/my_ntp/templates/ntp.conf.erb b/spec/fixtures/modules/my_ntp/templates/ntp.conf.erb new file mode 100644 index 0000000..40cf67c --- /dev/null +++ b/spec/fixtures/modules/my_ntp/templates/ntp.conf.erb @@ -0,0 +1,4 @@ +#my uber ntp config +# + +server foobar |