]> git.openstreetmap.org Git - chef.git/blob - cookbooks/sysctl/recipes/default.rb
Qualify property names
[chef.git] / cookbooks / sysctl / recipes / default.rb
1 #
2 # Cookbook Name:: sysctl
3 # Recipe:: default
4 #
5 # Copyright 2010, 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 #     http://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 package "procps"
21
22 directory "/etc/sysctl.d" do
23   owner "root"
24   group "root"
25   mode 0o755
26 end
27
28 execute "sysctl" do
29   action :nothing
30   command "/sbin/sysctl -p /etc/sysctl.d/60-chef.conf"
31 end
32
33 template "/etc/sysctl.d/60-chef.conf" do
34   source "chef.conf.erb"
35   owner "root"
36   group "root"
37   mode 0o644
38   notifies :run, "execute[sysctl]"
39 end
40
41 node[:sysctl].each_value do |group|
42   group[:parameters].each do |key, value|
43     sysctl_file = "/proc/sys/#{key.tr('.', '/')}"
44
45     file sysctl_file do
46       content "#{value}\n"
47       atomic_update false
48       only_if { File.exist?(sysctl_file) }
49     end
50   end
51 end