]> git.openstreetmap.org Git - chef.git/blob - cookbooks/sysctl/recipes/default.rb
Convert all notify/subscribe calls to the new style syntax
[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" do
21   action :install
22 end
23
24 directory "/etc/sysctl.d" do
25   owner "root"
26   group "root"
27   mode 0755
28 end
29
30 execute "sysctl" do
31   action :nothing
32   command "/sbin/sysctl -p /etc/sysctl.d/60-chef.conf"
33 end
34
35 template "/etc/sysctl.d/60-chef.conf" do
36   source "chef.conf.erb"
37   owner "root"
38   group "root"
39   mode 0644
40   notifies :run, "execute[sysctl]"
41 end
42
43 node[:sysctl].each_value do |group|
44   group[:parameters].each do |key,value|
45     sysctl_file = "/proc/sys/#{key.gsub('.', '/')}"
46
47     file sysctl_file do
48       content "#{value}\n"
49       atomic_update false
50       only_if { File.exists?(sysctl_file) }
51     end
52   end
53 end