]> git.openstreetmap.org Git - chef.git/blob - cookbooks/systemd/resources/tmpfile.rb
Convert more URLs to https
[chef.git] / cookbooks / systemd / resources / tmpfile.rb
1 #
2 # Cookbook Name:: systemd
3 # Resource:: systemd_tmpfile
4 #
5 # Copyright 2016, 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 :type, String, :required => true
23 property :path, String, :name_property => true
24 property :mode, String, :default => "-"
25 property :owner, String, :default => "-"
26 property :group, String, :default => "-"
27 property :age, String, :default => "-"
28 property :argument, String, :default => "-"
29
30 action :create do
31   template "/etc/tmpfiles.d/#{unit_name}.conf" do
32     cookbook "systemd"
33     source "tmpfile.erb"
34     owner "root"
35     group "root"
36     mode 0o644
37     variables new_resource.to_hash
38   end
39
40   execute "systemd-tmpfiles" do
41     action :nothing
42     command "systemd-tmpfiles --create /etc/tmpfiles.d/#{unit_name}.conf"
43     user "root"
44     group "root"
45     subscribes :run, "template[/etc/tmpfiles.d/#{unit_name}.conf]"
46   end
47 end
48
49 action :delete do
50   file "/etc/tmpfiles.d/#{unit_name}.conf" do
51     action :delete
52   end
53 end
54
55 action_class do
56   def unit_name
57     new_resource.path.sub(%r{^/}, "").gsub(%r{/}, "-")
58   end
59 end