]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/definitions/munin_plugin_conf.rb
63cecd0ab39ada1b80283b2a1dba3e2556e1aa18
[chef.git] / cookbooks / munin / definitions / munin_plugin_conf.rb
1 #
2 # Cookbook Name:: munin
3 # Definition:: munin_plugin_conf
4 #
5 # Copyright 2012, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 define :munin_plugin_conf, :action => :create, :variables => {} do
21   if params[:action] == :create
22     template "/etc/munin/plugin-conf.d/#{params[:name]}" do
23       if params[:cookbook]
24         cookbook params[:cookbook]
25       end
26       source params[:template]
27       owner "root"
28       group "root"
29       mode 0644
30       variables params[:variables].merge(:name => params[:name])
31       notifies :restart, resources(:service => "munin-node")
32     end
33   else
34     file "/etc/munin/plugin-conf.d/#{params[:name]}" do
35       action :delete
36     end
37   end
38 end