]> git.openstreetmap.org Git - chef.git/blob - cookbooks/systemd/resources/path.rb
Disable unreliable DNSSEC in test-kitchen
[chef.git] / cookbooks / systemd / resources / path.rb
1 #
2 # Cookbook:: systemd
3 # Resource:: systemd_path
4 #
5 # Copyright:: 2017, 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 :path, String, :name_property => true
25 property :description, String, :required => [:create]
26 property :after, [String, Array]
27 property :wants, [String, Array]
28 property :path_exists, [String, Array]
29 property :path_exists_glob, [String, Array]
30 property :path_changed, [String, Array]
31 property :path_modified, [String, Array]
32 property :directory_not_empty, [String, Array]
33 property :unit, String
34 property :make_directory, [true, false]
35 property :directory_mode, Integer
36
37 action :create do
38   path_variables = new_resource.to_hash
39
40   template "/etc/systemd/system/#{new_resource.path}.path" do
41     cookbook "systemd"
42     source "path.erb"
43     owner "root"
44     group "root"
45     mode "644"
46     variables path_variables
47   end
48
49   execute "systemctl-reload-#{new_resource.path}.path" do
50     action :nothing
51     command "systemctl daemon-reload"
52     user "root"
53     group "root"
54     subscribes :run, "template[/etc/systemd/system/#{new_resource.path}.path]"
55   end
56 end
57
58 action :delete do
59   file "/etc/systemd/system/#{new_resource.path}.path" do
60     action :delete
61   end
62
63   execute "systemctl-reload-#{new_resource.path}.path" do
64     action :nothing
65     command "systemctl daemon-reload"
66     user "root"
67     group "root"
68     subscribes :run, "file[/etc/systemd/system/#{new_resource.path}.path]"
69   end
70 end