]> git.openstreetmap.org Git - chef.git/blob - cookbooks/ohai/resources/plugin.rb
Drop custom ohai plugin path
[chef.git] / cookbooks / ohai / resources / plugin.rb
1 #
2 # Cookbook:: ohai
3 # Resource:: ohai_plugin
4 #
5 # Copyright:: 2015, 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 # https://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 unified_mode true
21
22 default_action :create
23
24 property :plugin, :kind_of => String, :name_property => true
25 property :template, :kind_of => String, :required => [:create]
26
27 action :create do
28   ohai new_resource.plugin do
29     action :nothing
30   end
31
32   directory "/etc/chef/ohai/plugins" do
33     owner "root"
34     group "root"
35     mode "755"
36     recursive true
37   end
38
39   declare_resource :template, plugin_path do
40     source new_resource.template
41     owner "root"
42     group "root"
43     mode "644"
44     notifies :reload, "ohai[#{new_resource.plugin}]"
45   end
46 end
47
48 action :delete do
49   file plugin_path do
50     action :delete
51   end
52 end
53
54 action_class do
55   def plugin_path
56     "/etc/chef/ohai/plugins/#{new_resource.plugin}.rb"
57   end
58 end