Skip to content

Commit ae3574a

Browse files
author
Michael van Rooijen
committed
Fixed formatting in all files (except the templates). Added a .gitignore to ignore unwanted system files. Fixed syntax formatting in the README. Removed old default file that got added as "git junk".
1 parent 0572cc0 commit ae3574a

15 files changed

+153
-151
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
*swp
3+
*swo

README.md

+71-45
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Description
22
===========
33

4-
Website:: https://github.com/brianbianco/redisio
4+
Website:: https://github.com/brianbianco/redisio
55

66
Installs and configures Redis server instances
77

88
Requirements
99
============
1010

11-
This cookbook builds redis from source, so it should work on any architecture for the supported distributions. Init scripts are installed into /etc/init.d/
11+
This cookbook builds redis from source, so it should work on any architecture for the supported distributions. Init scripts are installed into /etc/init.d/
1212

1313
Platforms
1414
---------
@@ -29,7 +29,7 @@ Usage
2929

3030
The redisio cookbook has 3 LWRP's and 4 recipes. For most use cases it isn't necessary to use the "install" LWRP and you should use the install recipe unless
3131
you have a good understanding of the required fields for the install LWRP. The service LWRP can be more useful if you have situations where you want to start,
32-
stop, or restart the redis service based on certain conditions.
32+
stop, or restart the redis service based on certain conditions.
3333

3434
If all you are interested in is having redis started and running as well as set to run in the default run levels, I suggest just using the install recipe followed by the enable recipe and not using the LWRP directly.
3535

@@ -42,16 +42,18 @@ Role File Examples
4242

4343
Install redis and setup an instance with default settings on default port, and start the service through a role file
4444

45+
```ruby
4546
run_list *%w[
4647
recipe[redisio::install]
4748
recipe[redisio::enable]
4849
]
4950

50-
default_attributes({
51-
})
51+
default_attributes({})
52+
```
5253

5354
Install redis and setup two instances on the same server, on different ports, with one slaved to the other through a role file
5455

56+
```ruby
5557
run_list *%w[
5658
recipe[redisio::install]
5759
recipe[redisio::enable]
@@ -60,28 +62,32 @@ run_list *%w[
6062
default_attributes({
6163
'redisio' => {
6264
'servers' => [
63-
{'port' => '6379'},
64-
{ 'port' => '6380', 'slaveof' => { 'address' => '127.0.0.1', 'port' => '6379'}}
65-
]
66-
}
65+
{'port' => '6379'},
66+
{'port' => '6380', 'slaveof' => { 'address' => '127.0.0.1', 'port' => '6379' }}
67+
]
68+
}
6769
})
70+
```
6871

6972
Install redis and setup two instances, on the same server, on different ports, with the data directory changed to /mnt/redis
7073

74+
```ruby
7175
run_list *%w[
7276
recipe[redisio::install]
7377
recipe[redisio::enable]
7478
]
7579

7680
default_attributes({
7781
'redisio' => {
78-
'default_settings' => {'datadir' => '/mnt/redis'}
79-
'servers' => [{'port' => '6379'},{'port' => '6380'}]
80-
}
82+
'default_settings' => {'datadir' => '/mnt/redis'},
83+
'servers' => [{'port' => '6379'}, {'port' => '6380'}]
84+
}
8185
})
86+
```
8287

8388
Install redis and setup three instances on the same server, changing the default data directory to /mnt/redis, each instance will use a different backup type, and one instance will use a different data dir
8489

90+
```ruby
8591
run_list *%w[
8692
recipe[redisio::install]
8793
recipe[redisio::enable]
@@ -91,12 +97,13 @@ default_attributes({
9197
'redisio' => {
9298
'default_settings' => { 'datadir' => '/mnt/redis/'},
9399
'servers' => [
94-
{'port' => '6379','backuptype' => 'aof'},
95-
{'port' => '6380','backuptype' => 'both'}
96-
{'port' => '6381','backuptype' => 'rdb', 'datadir' => '/mnt/redis6381' }
97-
]
100+
{'port' => '6379','backuptype' => 'aof'},
101+
{'port' => '6380','backuptype' => 'both'}
102+
{'port' => '6381','backuptype' => 'rdb', 'datadir' => '/mnt/redis6381'}
103+
]
98104
}
99105
})
106+
```
100107

101108

102109
LWRP Examples
@@ -110,12 +117,14 @@ install resource
110117

111118
It is important to note that this call has certain expectations for example, it expects the redis package to be in the format `redis-VERSION.tar.gz'. The servers resource expects an array of hashes where each hash is required to contain at a key-value pair of 'port' => '<port numbers'.
112119

120+
```ruby
113121
redisio_install "redis-servers" do
114-
version '2.4.10'
115-
download_url 'http://redis.googlecode.com/files/redis-2.4.10.tar.gz'
116-
default_settings node['redisio']['default_settings']
122+
version '2.4.10'
123+
download_url 'http://redis.googlecode.com/files/redis-2.4.10.tar.gz'
124+
default_settings node['redisio']['default_settings']
117125
servers node['redisio']['servers']
118126
end
127+
```
119128

120129
uninstall resource
121130
------------------
@@ -125,17 +134,20 @@ I generally don't recommend using this LWRP or recipe at all, but in the event y
125134

126135
This will only remove the redis binary files if they exist, nothing else.
127136

137+
```ruby
128138
redisio_uninstall "redis-servers" do
129139
action :run
130140
end
141+
```
131142

143+
This will remove the redis binaries, as well as the init script and configuration files for the specified server. This will not remove any data files
132144

133-
This will remove the redis binaries, as well as the init script and configuration files for the specified server. This will not remove any data files
134-
145+
```ruby
135146
redisio_uninstall "redis-servers" do
136147
servers [{'port' => '6379'}]
137148
action :run
138149
end
150+
```
139151

140152
service resource
141153
----------------
@@ -144,22 +156,27 @@ This LWRP provides the ability to stop, start, restart, disable and enable the r
144156

145157
Start and add to default runlevels the instance running on port 6379
146158

159+
```ruby
147160
redisio_service "6379" do
148161
action [:start,:enable]
149162
end
163+
```
150164

151165
Stop and remove from default runlevels the instance running on port 6379
152166

167+
```ruby
153168
redisio_service "6379" do
154169
action [:stop,:disable]
155170
end
171+
```
156172

157173
Restart the instance running on port 6380
158174

175+
```ruby
159176
redisio_service "6380" do
160177
action [:restart]
161178
end
162-
179+
```
163180

164181
Attributes
165182
==========
@@ -176,26 +193,29 @@ Default settings is a hash of default settings to be applied to to all instance.
176193
* `redisio['default_settings']` - { 'redis-option' => 'option setting' }
177194

178195
Available options and their defaults
179-
'user' => 'redis' - the user to own the redis datadir
180-
'group' => 'redis' - the group to own the redis datadir
181-
'homedir' => '/var/lib/redis' - the homedirectory of the user
182-
'shell' => Varies on distribution, check attributes file
183-
'configdir' => '/etc/redis' - config directory
184-
'homedir' => '/var/lib/redis', - home directory for the user
185-
'address' => nil,
186-
'backuptype' => 'rdb',
187-
'datadir' => '/var/lib/redis',
188-
'timeout' => '0',
189-
'loglevel' => 'verbose',
190-
'save' => ['900 1','300 10','60 10000'],
191-
'slaveof' => nil,
192-
'masterauth' => nil,
193-
'requirepass' => nil,
194-
'maxclients' => '0',
195-
'maxmemory' => nil,
196-
'maxmemorypolicy' => 'volatile-lru',
197-
'appendfsync' => 'everysec',
198-
'includes' => nil
196+
197+
```
198+
'user' => 'redis' - the user to own the redis datadir
199+
'group' => 'redis' - the group to own the redis datadir
200+
'homedir' => '/var/lib/redis' - the homedirectory of the user
201+
'shell' => Varies on distribution, check attributes file
202+
'configdir' => '/etc/redis' - config directory
203+
'homedir' => '/var/lib/redis', - home directory for the user
204+
'address' => nil,
205+
'backuptype' => 'rdb',
206+
'datadir' => '/var/lib/redis',
207+
'timeout' => '0',
208+
'loglevel' => 'verbose',
209+
'save' => ['900 1','300 10','60 10000'],
210+
'slaveof' => nil,
211+
'masterauth' => nil,
212+
'requirepass' => nil,
213+
'maxclients' => '0',
214+
'maxmemory' => nil,
215+
'maxmemorypolicy' => 'volatile-lru',
216+
'appendfsync' => 'everysec',
217+
'includes' => nil
218+
```
199219

200220
* `redisio['servers']` - An array where each item is a set of key value pairs for redis instance specific settings. The only required option is 'port'. These settings will override the options in 'default_settings', default is set to [{'port' => '6379'}]
201221

@@ -230,9 +250,11 @@ package file should be in the format <base_name><version_number>.<artifact_type>
230250

231251
package file after extraction should be inside of the directory <base_name><version_number>
232252

253+
```ruby
233254
install "redis" do
234255
action [:run,:nothing]
235256
end
257+
```
236258

237259
`uninstall`
238260
----------
@@ -244,17 +266,19 @@ Actions:
244266

245267
Attribute Parameters
246268

247-
* `servers` - an array of hashes containing the port number of instances to remove along with the binarires. (it is fine to pass in the same hash you used to install, even if there are additional
269+
* `servers` - an array of hashes containing the port number of instances to remove along with the binarires. (it is fine to pass in the same hash you used to install, even if there are additional
248270
only the port is used)
249271

272+
```ruby
250273
uninstall "redis" do
251274
action [:run,:nothing]
252275
end
276+
```
253277

254278
`service`
255279
---------
256280

257-
Actions:
281+
Actions:
258282

259283
* `start`
260284
* `stop`
@@ -264,15 +288,17 @@ Actions:
264288

265289
The name of the service must be the port that the redis server you want to perform the action on is identified by
266290

291+
```ruby
267292
service "redis_port" do
268293
action [:start,:stop,:restart,:enable,:disable]
269294
end
295+
```
270296

271297
License and Author
272298
==================
273299

274300
Author:: [Brian Bianco] (<[email protected]>)
275-
Author_Website:: http://www.brianbianco.com
301+
Author\_Website:: http://www.brianbianco.com
276302
IRC:: geekbri
277303

278304
Copyright 2012, Brian Bianco

attributes/default.rb

+34-35
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Cookbook Name:: redisio
33
# Attribute::default
44
#
5-
# Copyright 2012, Brian Bianco <[email protected]>
5+
# Copyright 2012, Brian Bianco <[email protected]>
66
#
77
# Licensed under the Apache License, Version 2.0 (the "License");
88
# you may not use this file except in compliance with the License.
@@ -18,18 +18,18 @@
1818
#
1919

2020
case node['platform']
21-
when 'ubuntu','debian'
22-
shell = '/bin/false'
23-
homedir = '/var/lib/redis'
24-
when 'centos','redhat','fedora','scientific','amazon','suse'
25-
shell = '/sbin/nologin'
26-
homedir = '/var/lib/redis' #this is necessary because selinux by default prevents the homedir from being managed in /var/lib/
27-
when 'fedora'
28-
shell = '/sbin/nologin'
29-
homedir = '/home/redis'
30-
else
31-
shell = '/bin/sh'
32-
homedir = '/redis'
21+
when 'ubuntu','debian'
22+
shell = '/bin/false'
23+
homedir = '/var/lib/redis'
24+
when 'centos','redhat','fedora','scientific','amazon','suse'
25+
shell = '/sbin/nologin'
26+
homedir = '/var/lib/redis' #this is necessary because selinux by default prevents the homedir from being managed in /var/lib/
27+
when 'fedora'
28+
shell = '/sbin/nologin'
29+
homedir = '/home/redis'
30+
else
31+
shell = '/bin/sh'
32+
homedir = '/redis'
3333
end
3434

3535
#Tarball and download related defaults
@@ -39,28 +39,27 @@
3939
default['redisio']['version'] = '2.4.10'
4040

4141
#Default settings for all redis instances, these can be overridden on a per server basis in the 'servers' hash
42-
default['redisio']['default_settings'] = {
43-
44-
'user' => 'redis',
45-
'group' => 'redis',
46-
'homedir' => homedir,
47-
'shell' => shell,
48-
'configdir' => '/etc/redis',
49-
'address' => nil,
50-
'backuptype' => 'rdb',
51-
'datadir' => '/var/lib/redis',
52-
'timeout' => '0',
53-
'loglevel' => 'verbose',
54-
'save' => ['900 1','300 10','60 10000'],
55-
'slaveof' => nil,
56-
'masterauth' => nil,
57-
'requirepass' => nil,
58-
'maxclients' => '0',
59-
'maxmemory' => nil,
60-
'maxmemorypolicy' => 'volatile-lru',
61-
'appendfsync' => 'everysec',
62-
'includes' => nil
63-
}
42+
default['redisio']['default_settings'] = {
43+
'user' => 'redis',
44+
'group' => 'redis',
45+
'homedir' => homedir,
46+
'shell' => shell,
47+
'configdir' => '/etc/redis',
48+
'address' => nil,
49+
'backuptype' => 'rdb',
50+
'datadir' => '/var/lib/redis',
51+
'timeout' => '0',
52+
'loglevel' => 'verbose',
53+
'save' => ['900 1','300 10','60 10000'],
54+
'slaveof' => nil,
55+
'masterauth' => nil,
56+
'requirepass' => nil,
57+
'maxclients' => '0',
58+
'maxmemory' => nil,
59+
'maxmemorypolicy' => 'volatile-lru',
60+
'appendfsync' => 'everysec',
61+
'includes' => nil
62+
}
6463

6564
#Individual server overrides, port is required and must be unique per instance, by default we setup a single redis instance on the default redis port of 6379
6665
default['redisio']['servers'] = [{'port' => '6379'}]

0 commit comments

Comments
 (0)