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