public
Last active

  • Download Gist
attributes-sysctl.rb
Ruby
1
sysctl Mash.new unless attribute?("sysctl")
default.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13
execute "sysctl" do
command "sysctl -n -e -q -p"
action :nothing
end
 
template "/etc/sysctl.conf" do
source "sysctl.conf.erb"
mode 0644
owner "root"
group "root"
variables( :sysctl => node[:sysctl] )
notifies :run, resources(:execute => "sysctl")
end
sysctl.conf.erb
HTML+ERB
1 2 3 4 5 6
# Managed by chef
<% if @sysctl.length > 0 %>
<% @sysctl.each do |k,v| %>
<%= k %> = <%= v %>
<% end %>
<% end %>
sysctl.rb
Ruby
1 2 3 4
define :sysctl do
key = params[:name]
@node[:sysctl][key] = params[:value]
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.