]> git.openstreetmap.org Git - chef.git/blob - cookbooks/ohai/resources/plugin.rb
Convert more URLs to https
[chef.git] / cookbooks / ohai / resources / plugin.rb
1 #
2 # Cookbook Name:: 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_attribute => 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   declare_resource :template, plugin_path do
31     source new_resource.template
32     owner "root"
33     group "root"
34     mode 0o644
35     notifies :reload, "ohai[#{new_resource.plugin}]"
36   end
37 end
38
39 action :delete do
40   file plugin_path do
41     action :delete
42   end
43 end
44
45 action_class do
46   def plugin_path
47     "/etc/chef/ohai/#{new_resource.plugin}.rb"
48   end
49 end