]> git.openstreetmap.org Git - chef.git/blob - cookbooks/sysfs/recipes/default.rb
Use strings for file modes
[chef.git] / cookbooks / sysfs / recipes / default.rb
1 #
2 # Cookbook:: sysfs
3 # Recipe:: default
4 #
5 # Copyright:: 2013, Tom Hughes
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 if node[:virtualization][:role] == "guest" &&
21    node[:virtualization][:system] == "lxd"
22   package "sysfsutils" do
23     action :purge
24   end
25 else
26   package "sysfsutils"
27
28   service "sysfsutils" do
29     action :enable
30     supports :status => false, :restart => true, :reload => false
31   end
32
33   template "/etc/sysfs.d/99-chef.conf" do
34     source "sysfs.conf.erb"
35     owner "root"
36     group "root"
37     mode "644"
38     notifies :restart, "service[sysfsutils]"
39   end
40
41   node[:sysfs].each_value do |group|
42     group[:parameters].each do |key, value|
43       sysfs_file = "/sys/#{key}"
44
45       file sysfs_file do
46         content "#{value}\n"
47         atomic_update false
48         ignore_failure true
49       end
50     end
51   end
52 end