diff options
author | mh <mh@immerda.ch> | 2014-06-13 12:25:48 +0200 |
---|---|---|
committer | mh <mh@immerda.ch> | 2014-06-13 12:25:48 +0200 |
commit | 88d197da8cedd5d711db043995f725ebe66b6ed6 (patch) | |
tree | c16dd06790a667ed1152fe7ff184379e7a1976df | |
parent | ea1cf47e6a86d5641fc6655bff553c4dbe55b897 (diff) |
implement #38 - allow config to be an array
-rw-r--r-- | manifests/plugin.pp | 4 | ||||
-rw-r--r-- | spec/defines/munin_plugin_spec.rb | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/manifests/plugin.pp b/manifests/plugin.pp index ef82f90..37d0077 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -32,9 +32,9 @@ define munin::plugin ( seltype => 'munin_etc_t', } } - if $config != '' { + if !empty($config) { file { "/etc/munin/plugin-conf.d/${name}.conf": - content => "[${name}]\n${config}\n", + content => inline_template("[<%= @name %>]\n<%= Array(@config).join(\"\n\") %>\n"), owner => root, group => 0, mode => '0640', diff --git a/spec/defines/munin_plugin_spec.rb b/spec/defines/munin_plugin_spec.rb index 3d7e9e3..0e7306a 100644 --- a/spec/defines/munin_plugin_spec.rb +++ b/spec/defines/munin_plugin_spec.rb @@ -30,6 +30,23 @@ describe 'munin::plugin' do ) } end + context 'present and config as an array' do + let(:params) do + { :config => [ 'env.user root', 'env.group root' ] } + end + it { should contain_file('/etc/munin/plugins/users').with( + :ensure => 'link', + :target => '/usr/share/munin/plugins/users', + :notify => 'Service[munin-node]' + ) } + it { should contain_file('/etc/munin/plugin-conf.d/users.conf').with( + :content => "[users]\nenv.user root\nenv.group root\n", + :owner => 'root', + :group => 0, + :mode => '0640' + ) } + end + context 'absent' do let(:params) do { :ensure => 'absent' } |