Skip to content

Commit 75e5016

Browse files
committed
initial commit
0 parents  commit 75e5016

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

README.rdoc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
= DESCRIPTION:
2+
Set sysctl values from Chef!
3+
4+
= REQUIREMENTS:
5+
6+
= ATTRIBUTES:
7+
node[:sysctl] = A namespace for sysctl settings.
8+
9+
= USAGE:
10+
There are two ways of setting sysctl values:
11+
1. Set chef attributes in the _sysctl_ namespace, E.G.:
12+
<tt>default[:sysctl][:vm][:swappiness] = 20</tt>
13+
2. Set values in a cookbook_file - 69-chef-static.conf
14+

metadata.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "sysctl",
3+
"description": "Configures sysctl parameters",
4+
"long_description": "= DESCRIPTION:\nSet sysctl values from Chef!\n\n= REQUIREMENTS:\n\n= ATTRIBUTES:\nnode[:sysctl] = A namespace for sysctl settings.\n\n= USAGE:\nThere are two ways of setting sysctl values:\n1. Set chef attributes in the _sysctl_ namespace, E.G.:\n<tt>default[:sysctl][:vm][:swappiness] = 20</tt>\n2. Set values in a cookbook_file - 69-chef-static.conf\n\n",
5+
"maintainer": "Fewbytes Technologies",
6+
"maintainer_email": "[email protected]",
7+
"license": "Apache v2.0",
8+
"platforms": {
9+
"ubuntu": ">= 0.0.0",
10+
"debian": ">= 0.0.0"
11+
},
12+
"dependencies": {
13+
},
14+
"recommendations": {
15+
},
16+
"suggestions": {
17+
},
18+
"conflicting": {
19+
},
20+
"providing": {
21+
},
22+
"replacing": {
23+
},
24+
"attributes": {
25+
},
26+
"groupings": {
27+
},
28+
"recipes": {
29+
},
30+
"version": "0.1.0"
31+
}

metadata.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
maintainer "Fewbytes Technologies"
2+
maintainer_email "[email protected]"
3+
license "Apache v2.0"
4+
description "Configures sysctl parameters"
5+
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
6+
version "0.1.0"
7+
supports "ubuntu"
8+
supports "debian"

recipes/default.rb

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Cookbook Name:: sysctl
3+
# Recipe:: default
4+
#
5+
# Copyright 2011, Fewbytes Technologies LTD
6+
#
7+
8+
def compile_attr(prefix, v)
9+
case v
10+
when Array
11+
return "#{prefix}=#{v.join(" ")}"
12+
when String, Fixnum, Float, Symbol
13+
"#{prefix}=#{v}"
14+
when Hash, Chef::Node::Attribute
15+
prefix += "." unless prefix.empty?
16+
return v.map {|key, value| compile_attr("#{prefix}#{key}", value)}.flatten
17+
else
18+
raise Chef::Exceptions::UnsupportedAction, "Sysctl cookbook can't handle values of type: #{v.class}"
19+
end
20+
end
21+
22+
if node.attribute?(:sysctl)
23+
24+
attr_txt = compile_attr("", node[:sysctl]).join("\n") + "\n"
25+
26+
file "/etc/sysctl.d/68-chef-attributes.conf" do
27+
content attr_txt
28+
mode "0644"
29+
notifies :start, "service[procps]"
30+
end
31+
end
32+
33+
cookbook_file "/etc/sysctl.d/69-chef-static.conf" do
34+
ignore_failure true
35+
mode "0644"
36+
notifies :start, "service[procps]"
37+
end
38+
39+
service "procps"

0 commit comments

Comments
 (0)