rubber 1.7.2 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/CHANGELOG +6 -0
  2. data/VERSION +1 -1
  3. data/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +3 -3
  4. data/generators/vulcanize/templates/base/config/rubber/rubber.yml +8 -0
  5. data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +2 -2
  6. data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +0 -1
  7. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +1 -0
  8. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +4 -2
  9. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +6 -0
  10. data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +3 -3
  11. data/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +43 -16
  12. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/munin-postgresql.conf +7 -0
  13. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +270 -243
  14. data/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +3 -3
  15. data/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +44 -5
  16. data/generators/vulcanize/templates/redis/config/rubber/role/redis/redis.conf +222 -43
  17. data/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +5 -0
  18. data/lib/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +3 -3
  19. data/lib/generators/vulcanize/templates/base/config/rubber/rubber.yml +8 -0
  20. data/lib/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +2 -2
  21. data/lib/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +0 -1
  22. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +1 -0
  23. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +4 -2
  24. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +6 -0
  25. data/lib/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +3 -3
  26. data/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +43 -16
  27. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/munin-postgresql.conf +7 -0
  28. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +270 -243
  29. data/lib/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +3 -3
  30. data/lib/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +44 -5
  31. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/redis.conf +222 -43
  32. data/lib/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +5 -0
  33. data/lib/rubber/cloud/aws.rb +7 -0
  34. data/lib/rubber/recipes/rubber/instances.rb +8 -0
  35. data/lib/rubber/recipes/rubber/tags.rb +12 -0
  36. data/lib/rubber/recipes/rubber/volumes.rb +5 -4
  37. data/lib/rubber/tag.rb +16 -0
  38. data/lib/rubber/tasks/rubber.rb +1 -1
  39. metadata +14 -10
@@ -18,12 +18,12 @@ db_backup_cmd: "nice sudo -u postgres pg_dumpall -U postgres | gzip -c > %backup
18
18
  # its standard input
19
19
  db_restore_cmd: "zcat - | psql -Uroot -h %host% %name%"
20
20
 
21
- postgresql_ver: 8.4
21
+ postgresql_ver: 9.0
22
22
  postgresql_conf_dir: "/etc/postgresql/#{postgresql_ver}/main"
23
23
  postgresql_data_dir: /mnt/postgresql/data
24
24
  postgresql_archive_dir: /mnt/postgresql/archive
25
25
  postgresql_pid_file: "/var/run/postgresql/#{postgresql_ver}-main.pid"
26
- postgresql_ctl: "/usr/bin/env service postgresql-#{postgresql_ver}"
26
+ postgresql_ctl: "/usr/bin/env service postgresql"
27
27
 
28
28
  # Capistrano needs db:primary role for migrate to work,
29
29
  # so we might as well just make consistent across the board
@@ -42,4 +42,4 @@ roles:
42
42
  postgresql_slave:
43
43
  db_server_id: 2
44
44
  db:
45
- packages: [postgresql]
45
+ packages: [postgresql-9.0, libdbd-pg-perl]
@@ -4,17 +4,56 @@ namespace :rubber do
4
4
 
5
5
  rubber.allow_optional_tasks(self)
6
6
 
7
+ before "rubber:install_packages", "rubber:redis:setup_apt_sources"
8
+
9
+ task :setup_apt_sources, :roles => :redis do
10
+ rsudo "add-apt-repository ppa:soren/nova"
11
+ end
12
+
7
13
  after "rubber:install_packages", "rubber:redis:custom_install"
8
14
 
9
15
  task :custom_install, :roles => :redis do
10
- custom_package('http://ftp.us.debian.org/debian/pool/main/r/redis/', 'redis-server', '1.2.6-1', '! -x /usr/bin/redis-server')
11
- # force redis config regen so db dir gets recreated when creating staging from a bundle
12
- rsudo "rm -f /etc/redis/redis.conf"
16
+ rubber.sudo_script 'install_redis', <<-ENDSCRIPT
17
+ if ! redis-server --version | grep "#{rubber_env.redis_server_version}" &> /dev/null; then
18
+ # Fetch the sources.
19
+ wget http://redis.googlecode.com/files/redis-#{rubber_env.redis_server_version}.tar.gz
20
+ tar -zxf redis-#{rubber_env.redis_server_version}.tar.gz
21
+
22
+ # Build the binaries.
23
+ cd redis-#{rubber_env.redis_server_version}
24
+ make
25
+
26
+ # Install the binaries.
27
+ /etc/init.d/redis-server stop
28
+
29
+ mv redis-benchmark /usr/bin/
30
+ mv redis-check-aof /usr/bin/
31
+ mv redis-check-dump /usr/bin/
32
+ mv redis-cli /usr/bin/
33
+ mv redis-server /usr/bin/
34
+
35
+ /etc/init.d/redis-server start
36
+
37
+ # Clean up after ourselves.
38
+ cd ..
39
+ rm -rf redis-#{rubber_env.redis_server_version}
40
+ rm redis-#{rubber_env.redis_server_version}.tar.gz
41
+ fi
42
+ ENDSCRIPT
43
+ end
44
+
45
+ after "rubber:bootstrap", "rubber:redis:bootstrap"
46
+
47
+ task :bootstrap, :roles => :redis do
48
+ rubber.sudo_script 'bootstrap_redis', <<-ENDSCRIPT
49
+ mkdir -p #{rubber_env.redis_db_dir}
50
+ chown -R redis:redis #{rubber_env.redis_db_dir}
51
+ ENDSCRIPT
13
52
  end
14
53
 
15
54
  desc "Stops the redis server"
16
- task :stop, :roles => :redis do
17
- rsudo "/etc/init.d/redis-server stop; exit 0"
55
+ task :stop, :roles => :redis, :on_error => :continue do
56
+ rsudo "/etc/init.d/redis-server stop"
18
57
  end
19
58
 
20
59
  desc "Starts the redis server"
@@ -9,25 +9,57 @@
9
9
 
10
10
  # Redis configuration file example
11
11
 
12
+ # Note on units: when memory size is needed, it is possible to specifiy
13
+ # it in the usual form of 1k 5GB 4M and so forth:
14
+ #
15
+ # 1k => 1000 bytes
16
+ # 1kb => 1024 bytes
17
+ # 1m => 1000000 bytes
18
+ # 1mb => 1024*1024 bytes
19
+ # 1g => 1000000000 bytes
20
+ # 1gb => 1024*1024*1024 bytes
21
+ #
22
+ # units are case insensitive so 1GB 1Gb 1gB are all the same.
23
+
12
24
  # By default Redis does not run as a daemon. Use 'yes' if you need it.
13
25
  # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
14
26
  daemonize yes
15
27
 
16
- # When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
17
- # You can specify a custom pid file location here.
28
+ # When running daemonized, Redis writes a pid file in /var/run/redis.pid by
29
+ # default. You can specify a custom pid file location here.
18
30
  pidfile /var/run/redis.pid
19
31
 
20
32
  # Accept connections on the specified port, default is 6379
21
33
  port 6379
22
34
 
23
35
  # If you want you can bind a single interface, if the bind option is not
24
- # specified all the interfaces will listen for connections.
36
+ # specified all the interfaces will listen for incoming connections.
25
37
  #
26
38
  # bind 127.0.0.1
27
39
 
28
40
  # Close the connection after a client is idle for N seconds (0 to disable)
29
41
  timeout 300
30
42
 
43
+ # Set server verbosity to 'debug'
44
+ # it can be one of:
45
+ # debug (a lot of information, useful for development/testing)
46
+ # verbose (many rarely useful info, but not a mess like the debug level)
47
+ # notice (moderately verbose, what you want in production probably)
48
+ # warning (only very important / critical messages are logged)
49
+ loglevel notice
50
+
51
+ # Specify the log file name. Also 'stdout' can be used to force
52
+ # Redis to log on the standard output. Note that if you use standard
53
+ # output for logging but daemonize, logs will be sent to /dev/null
54
+ logfile /var/log/redis/redis-server.log
55
+
56
+ # Set the number of databases. The default database is DB 0, you can select
57
+ # a different one on a per-connection basis using SELECT <dbid> where
58
+ # dbid is a number between 0 and 'databases'-1
59
+ databases 16
60
+
61
+ ################################ SNAPSHOTTING #################################
62
+ #
31
63
  # Save the DB on disk:
32
64
  #
33
65
  # save <seconds> <changes>
@@ -39,43 +71,48 @@ timeout 300
39
71
  # after 900 sec (15 min) if at least 1 key changed
40
72
  # after 300 sec (5 min) if at least 10 keys changed
41
73
  # after 60 sec if at least 10000 keys changed
74
+ #
75
+ # Note: you can disable saving at all commenting all the "save" lines.
76
+
42
77
  save 900 1
43
78
  save 300 10
44
79
  save 60 10000
45
80
 
81
+ # Compress string objects using LZF when dump .rdb databases?
82
+ # For default that's set to 'yes' as it's almost always a win.
83
+ # If you want to save some CPU in the saving child set it to 'no' but
84
+ # the dataset will likely be bigger if you have compressible values or keys.
85
+ rdbcompression yes
86
+
46
87
  # The filename where to dump the DB
47
88
  dbfilename dump.rdb
48
89
 
49
- # For default save/load DB in/from the working directory
50
- # Note that you must specify a directory not a file name.
90
+ # The working directory.
91
+ #
92
+ # The DB will be written inside this directory, with the filename specified
93
+ # above using the 'dbfilename' configuration directive.
94
+ #
95
+ # Also the Append Only File will be created inside this directory.
96
+ #
97
+ # Note that you must specify a directory here, not a file name.
51
98
  dir <%= rubber_env.redis_db_dir %>
52
99
 
53
- # Set server verbosity to 'debug'
54
- # it can be one of:
55
- # debug (a lot of information, useful for development/testing)
56
- # notice (moderately verbose, what you want in production probably)
57
- # warning (only very important / critical messages are logged)
58
- loglevel notice
59
-
60
- # Specify the log file name. Also 'stdout' can be used to force
61
- # the demon to log on the standard output. Note that if you use standard
62
- # output for logging but daemonize, logs will be sent to /dev/null
63
- logfile /var/log/redis/redis-server.log
64
-
65
- # Set the number of databases. The default database is DB 0, you can select
66
- # a different one on a per-connection basis using SELECT <dbid> where
67
- # dbid is a number between 0 and 'databases'-1
68
- databases 16
69
-
70
100
  ################################# REPLICATION #################################
71
101
 
72
102
  # Master-Slave replication. Use slaveof to make a Redis instance a copy of
73
103
  # another Redis server. Note that the configuration is local to the slave
74
104
  # so for example it is possible to configure the slave to save the DB with a
75
105
  # different interval, or to listen to another port, and so on.
76
-
106
+ #
77
107
  # slaveof <masterip> <masterport>
78
108
 
109
+ # If the master is password protected (using the "requirepass" configuration
110
+ # directive below) it is possible to tell the slave to authenticate before
111
+ # starting the replication synchronization process, otherwise the master will
112
+ # refuse the slave request.
113
+ #
114
+ # masterauth <master-password>
115
+
79
116
  ################################## SECURITY ###################################
80
117
 
81
118
  # Require clients to issue AUTH <PASSWORD> before processing any other
@@ -84,17 +121,21 @@ databases 16
84
121
  #
85
122
  # This should stay commented out for backward compatibility and because most
86
123
  # people do not need auth (e.g. they run their own servers).
87
-
124
+ #
125
+ # Warning: since Redis is pretty fast an outside user can try up to
126
+ # 150k passwords per second against a good box. This means that you should
127
+ # use a very strong password otherwise it will be very easy to break.
128
+ #
88
129
  # requirepass foobared
89
130
 
90
131
  ################################### LIMITS ####################################
91
132
 
92
133
  # Set the max number of connected clients at the same time. By default there
93
134
  # is no limit, and it's up to the number of file descriptors the Redis process
94
- # is able to open. The special value '0' means no limts.
135
+ # is able to open. The special value '0' means no limits.
95
136
  # Once the limit is reached Redis will close all the new connections sending
96
137
  # an error 'max number of clients reached'.
97
-
138
+ #
98
139
  # maxclients 128
99
140
 
100
141
  # Don't use more memory than the specified amount of bytes.
@@ -113,9 +154,127 @@ databases 16
113
154
  # it is going to use too much memory in the long run, and you'll have the time
114
155
  # to upgrade. With maxmemory after the limit is reached you'll start to get
115
156
  # errors for write operations, and this may even lead to DB inconsistency.
116
-
157
+ #
117
158
  # maxmemory <bytes>
118
159
 
160
+ ############################## APPEND ONLY MODE ###############################
161
+
162
+ # By default Redis asynchronously dumps the dataset on disk. If you can live
163
+ # with the idea that the latest records will be lost if something like a crash
164
+ # happens this is the preferred way to run Redis. If instead you care a lot
165
+ # about your data and don't want to that a single record can get lost you should
166
+ # enable the append only mode: when this mode is enabled Redis will append
167
+ # every write operation received in the file appendonly.aof. This file will
168
+ # be read on startup in order to rebuild the full dataset in memory.
169
+ #
170
+ # Note that you can have both the async dumps and the append only file if you
171
+ # like (you have to comment the "save" statements above to disable the dumps).
172
+ # Still if append only mode is enabled Redis will load the data from the
173
+ # log file at startup ignoring the dump.rdb file.
174
+ #
175
+ # IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
176
+ # log file in background when it gets too big.
177
+
178
+ appendonly no
179
+
180
+ # The name of the append only file (default: "appendonly.aof")
181
+ # appendfilename appendonly.aof
182
+
183
+ # The fsync() call tells the Operating System to actually write data on disk
184
+ # instead to wait for more data in the output buffer. Some OS will really flush
185
+ # data on disk, some other OS will just try to do it ASAP.
186
+ #
187
+ # Redis supports three different modes:
188
+ #
189
+ # no: don't fsync, just let the OS flush the data when it wants. Faster.
190
+ # always: fsync after every write to the append only log . Slow, Safest.
191
+ # everysec: fsync only if one second passed since the last fsync. Compromise.
192
+ #
193
+ # The default is "everysec" that's usually the right compromise between
194
+ # speed and data safety. It's up to you to understand if you can relax this to
195
+ # "no" that will will let the operating system flush the output buffer when
196
+ # it wants, for better performances (but if you can live with the idea of
197
+ # some data loss consider the default persistence mode that's snapshotting),
198
+ # or on the contrary, use "always" that's very slow but a bit safer than
199
+ # everysec.
200
+ #
201
+ # If unsure, use "everysec".
202
+
203
+ # appendfsync always
204
+ appendfsync everysec
205
+ # appendfsync no
206
+
207
+ ################################ VIRTUAL MEMORY ###############################
208
+
209
+ # Virtual Memory allows Redis to work with datasets bigger than the actual
210
+ # amount of RAM needed to hold the whole dataset in memory.
211
+ # In order to do so very used keys are taken in memory while the other keys
212
+ # are swapped into a swap file, similarly to what operating systems do
213
+ # with memory pages.
214
+ #
215
+ # To enable VM just set 'vm-enabled' to yes, and set the following three
216
+ # VM parameters accordingly to your needs.
217
+
218
+ vm-enabled no
219
+
220
+ # This is the path of the Redis swap file. As you can guess, swap files
221
+ # can't be shared by different Redis instances, so make sure to use a swap
222
+ # file for every redis process you are running. Redis will complain if the
223
+ # swap file is already in use.
224
+ #
225
+ # The best kind of storage for the Redis swap file (that's accessed at random)
226
+ # is a Solid State Disk (SSD).
227
+ #
228
+ # *** WARNING *** if you are using a shared hosting the default of putting
229
+ # the swap file under /tmp is not secure. Create a dir with access granted
230
+ # only to Redis user and configure Redis to create the swap file there.
231
+ vm-swap-file <%= rubber_env.redis_db_dir %>/redis.swap
232
+
233
+ # vm-max-memory configures the VM to use at max the specified amount of
234
+ # RAM. Everything that deos not fit will be swapped on disk *if* possible, that
235
+ # is, if there is still enough contiguous space in the swap file.
236
+ #
237
+ # With vm-max-memory 0 the system will swap everything it can. Not a good
238
+ # default, just specify the max amount of RAM you can in bytes, but it's
239
+ # better to leave some margin. For instance specify an amount of RAM
240
+ # that's more or less between 60 and 80% of your free RAM.
241
+ vm-max-memory 0
242
+
243
+ # Redis swap files is split into pages. An object can be saved using multiple
244
+ # contiguous pages, but pages can't be shared between different objects.
245
+ # So if your page is too big, small objects swapped out on disk will waste
246
+ # a lot of space. If you page is too small, there is less space in the swap
247
+ # file (assuming you configured the same number of total swap file pages).
248
+ #
249
+ # If you use a lot of small objects, use a page size of 64 or 32 bytes.
250
+ # If you use a lot of big objects, use a bigger page size.
251
+ # If unsure, use the default :)
252
+ vm-page-size 32
253
+
254
+ # Number of total memory pages in the swap file.
255
+ # Given that the page table (a bitmap of free/used pages) is taken in memory,
256
+ # every 8 pages on disk will consume 1 byte of RAM.
257
+ #
258
+ # The total swap size is vm-page-size * vm-pages
259
+ #
260
+ # With the default of 32-bytes memory pages and 134217728 pages Redis will
261
+ # use a 4 GB swap file, that will use 16 MB of RAM for the page table.
262
+ #
263
+ # It's better to use the smallest acceptable value for your application,
264
+ # but the default is large in order to work in most conditions.
265
+ vm-pages 134217728
266
+
267
+ # Max number of VM I/O threads running at the same time.
268
+ # This threads are used to read/write data from/to swap file, since they
269
+ # also encode and decode objects from disk to memory or the reverse, a bigger
270
+ # number of threads can help with big objects even if they can't help with
271
+ # I/O itself as the physical device may not be able to couple with many
272
+ # reads/writes operations at the same time.
273
+ #
274
+ # The special value of 0 turn off threaded I/O and enables the blocking
275
+ # Virtual Memory implementation.
276
+ vm-max-threads 4
277
+
119
278
  ############################### ADVANCED CONFIG ###############################
120
279
 
121
280
  # Glue small output buffers together in order to send small replies in a
@@ -123,19 +282,39 @@ databases 16
123
282
  # in terms of number of queries per second. Use 'yes' if unsure.
124
283
  glueoutputbuf yes
125
284
 
126
- # Use object sharing. Can save a lot of memory if you have many common
127
- # string in your dataset, but performs lookups against the shared objects
128
- # pool so it uses more CPU and can be a bit slower. Usually it's a good
129
- # idea.
130
- #
131
- # When object sharing is enabled (shareobjects yes) you can use
132
- # shareobjectspoolsize to control the size of the pool used in order to try
133
- # object sharing. A bigger pool size will lead to better sharing capabilities.
134
- # In general you want this value to be at least the double of the number of
135
- # very common strings you have in your dataset.
136
- #
137
- # WARNING: object sharing is experimental, don't enable this feature
138
- # in production before of Redis 1.0-stable. Still please try this feature in
139
- # your development environment so that we can test it better.
140
- shareobjects no
141
- shareobjectspoolsize 1024
285
+ # Hashes are encoded in a special way (much more memory efficient) when they
286
+ # have at max a given numer of elements, and the biggest element does not
287
+ # exceed a given threshold. You can configure this limits with the following
288
+ # configuration directives.
289
+ hash-max-zipmap-entries 64
290
+ hash-max-zipmap-value 512
291
+
292
+ # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
293
+ # order to help rehashing the main Redis hash table (the one mapping top-level
294
+ # keys to values). The hash table implementation redis uses (see dict.c)
295
+ # performs a lazy rehashing: the more operation you run into an hash table
296
+ # that is rhashing, the more rehashing "steps" are performed, so if the
297
+ # server is idle the rehashing is never complete and some more memory is used
298
+ # by the hash table.
299
+ #
300
+ # The default is to use this millisecond 10 times every second in order to
301
+ # active rehashing the main dictionaries, freeing memory when possible.
302
+ #
303
+ # If unsure:
304
+ # use "activerehashing no" if you have hard latency requirements and it is
305
+ # not a good thing in your environment that Redis can reply form time to time
306
+ # to queries with 2 milliseconds delay.
307
+ #
308
+ # use "activerehashing yes" if you don't have such hard requirements but
309
+ # want to free memory asap when possible.
310
+ activerehashing yes
311
+
312
+ ################################## INCLUDES ###################################
313
+
314
+ # Include one or more other config files here. This is useful if you
315
+ # have a standard template that goes to all redis server but also need
316
+ # to customize a few per-server settings. Include files can include
317
+ # other files, so use this wisely.
318
+ #
319
+ # include /path/to/local.conf
320
+ # include /path/to/other.conf
@@ -1,4 +1,9 @@
1
+ redis_server_version: 2.0.4
1
2
 
2
3
  redis_db_dir: /mnt/redis
3
4
 
4
5
  gems: [redis]
6
+
7
+ roles:
8
+ redis:
9
+ packages: [redis-server]
@@ -12,15 +12,15 @@
12
12
  packages: [build-essential, git-core, subversion, curl, autoconf, bison, ruby, zlib1g-dev, libssl-dev, libreadline5-dev, libxml2-dev]
13
13
 
14
14
  # REQUIRED: the version of rvm itself
15
- rvm_version: 1.0.15
15
+ rvm_version: 1.1.3
16
16
 
17
17
  # REQUIRED: Set to the rvm version string for the ruby version you wish to use
18
18
  # Run "rvm list known" to see the list of possible options
19
19
  rvm_ruby: 1.9.2
20
20
 
21
21
  # When rvm is installed as root, and you set the default, it symlinks ruby executables
22
- # into /usr/local
23
- ruby_prefix: /usr/local
22
+ # into /usr/local/rvm
23
+ ruby_prefix: /usr/local/rvm
24
24
 
25
25
  rvm_prefix: /usr/local/rvm
26
26