rubber 1.1.7 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.7
1
+ 1.2.0
@@ -13,20 +13,20 @@ namespace :rubber do
13
13
  rubber_instances.filtered.each do |ic|
14
14
  env = rubber_cfg.environment.bind(ic.role_names, ic.name)
15
15
  if env.use_enterprise_ruby
16
- ent_ruby_hosts << ic.full_name
16
+ ent_ruby_hosts << ic.full_name unless ic.windows?
17
17
  end
18
18
  end
19
19
 
20
20
  if ent_ruby_hosts.size > 0
21
21
  task :_install_enterprise_ruby, :hosts => ent_ruby_hosts do
22
- ver = "1.8.7-2009.10"
22
+ ver = "1.8.7-2010.01"
23
23
  rubber.run_script "install_ruby-enterprise", <<-ENDSCRIPT
24
- if [[ ! `ruby --version 2> /dev/null` =~ "Ruby Enterprise Edition 2009.10" ]]; then
24
+ if [[ ! `ruby --version 2> /dev/null` =~ "Ruby Enterprise Edition 2010.01" ]]; then
25
25
  arch=`uname -m`
26
26
  if [ "$arch" = "x86_64" ]; then
27
- src="http://rubyforge.org/frs/download.php/66163/ruby-enterprise_#{ver}_amd64.deb"
27
+ src="http://rubyforge.org/frs/download.php/68720/ruby-enterprise_#{ver}_amd64.deb"
28
28
  else
29
- src="http://rubyforge.org/frs/download.php/66164/ruby-enterprise_#{ver}_i386.deb"
29
+ src="http://rubyforge.org/frs/download.php/68718/ruby-enterprise_#{ver}_i386.deb"
30
30
  fi
31
31
  src_file="${src##*/}"
32
32
  wget -qP /tmp ${src}
@@ -82,6 +82,19 @@ cloud_providers:
82
82
  # m1.small or m1.large or m1.xlarge
83
83
  image_type: m1.small
84
84
 
85
+ # OPTIONAL: EC2 spot instance request support.
86
+ #
87
+ # Enables the creation of spot instance requests. Rubber will wait synchronously until the request is fulfilled,
88
+ # at which point it will begin initializing the instance, unless spot_instance_request_timeout is set.
89
+ # spot_instance: true
90
+ #
91
+ # The maximum price you would like to pay for your spot instance.
92
+ # spot_price: "0.085"
93
+ #
94
+ # If a spot instance request can't be fulfilled in 3 minutes, fallback to on-demand instance creation. If not set,
95
+ # the default is infinite.
96
+ # spot_instance_request_timeout: 180
97
+
85
98
  # REQUIRED the cloud provider to use
86
99
  #
87
100
  cloud_provider: aws
@@ -0,0 +1,589 @@
1
+ <%-
2
+ @path = "#{rubber_env.jetty_dir}/bin/jetty.sh"
3
+ @perms = 0744
4
+ %>
5
+
6
+ #!/bin/bash
7
+ #
8
+ # Startup script for jetty under *nix systems (it works under NT/cygwin too).
9
+
10
+ # To get the service to restart correctly on reboot, uncomment below (3 lines):
11
+ # ========================
12
+ # chkconfig: 3 99 99
13
+ # description: Jetty 7 webserver
14
+ # processname: jetty
15
+ # ========================
16
+
17
+ # Configuration files
18
+ #
19
+ # /etc/default/jetty
20
+ # If it exists, this is read at the start of script. It may perform any
21
+ # sequence of shell commands, like setting relevant environment variables.
22
+ #
23
+ # $HOME/.jettyrc
24
+ # If it exists, this is read at the start of script. It may perform any
25
+ # sequence of shell commands, like setting relevant environment variables.
26
+ #
27
+ # /etc/jetty.conf
28
+ # If found, and no configurations were given on the command line,
29
+ # the file will be used as this script's configuration.
30
+ # Each line in the file may contain:
31
+ # - A comment denoted by the pound (#) sign as first non-blank character.
32
+ # - The path to a regular file, which will be passed to jetty as a
33
+ # config.xml file.
34
+ # - The path to a directory. Each *.xml file in the directory will be
35
+ # passed to jetty as a config.xml file.
36
+ #
37
+ # The files will be checked for existence before being passed to jetty.
38
+ #
39
+ # $JETTY_HOME/etc/jetty.xml
40
+ # If found, used as this script's configuration file, but only if
41
+ # /etc/jetty.conf was not present. See above.
42
+ #
43
+ # Configuration variables
44
+ #
45
+ # JAVA_HOME
46
+ # Home of Java installation.
47
+ #
48
+ # JAVA
49
+ # Command to invoke Java. If not set, $JAVA_HOME/bin/java will be
50
+ # used.
51
+ #
52
+ # JAVA_OPTIONS
53
+ # Extra options to pass to the JVM
54
+
55
+ JAVA_OPTIONS="<%= rubber_env.jetty_jvm_options %>"
56
+
57
+ #
58
+ # JETTY_HOME
59
+ # Where Jetty is installed. If not set, the script will try go
60
+ # guess it by first looking at the invocation path for the script,
61
+ # and then by looking in standard locations as $HOME/opt/jetty
62
+ # and /opt/jetty. The java system property "jetty.home" will be
63
+ # set to this value for use by configure.xml files, f.e.:
64
+ #
65
+ # <Arg><SystemProperty name="jetty.home" default="."/>/webapps/jetty.war</Arg>
66
+ #
67
+ # JETTY_PORT
68
+ # Override the default port for Jetty servers. If not set then the
69
+ # default value in the xml configuration file will be used. The java
70
+ # system property "jetty.port" will be set to this value for use in
71
+ # configure.xml files. For example, the following idiom is widely
72
+ # used in the demo config files to respect this property in Listener
73
+ # configuration elements:
74
+ #
75
+ # <Set name="Port"><SystemProperty name="jetty.port" default="8080"/></Set>
76
+ #
77
+ # Note: that the config file could ignore this property simply by saying:
78
+ #
79
+ # <Set name="Port">8080</Set>
80
+ #
81
+ # JETTY_RUN
82
+ # Where the jetty.pid file should be stored. It defaults to the
83
+ # first available of /var/run, /usr/var/run, and /tmp if not set.
84
+ #
85
+ # JETTY_PID
86
+ # The Jetty PID file, defaults to $JETTY_RUN/jetty.pid
87
+ #
88
+ # JETTY_ARGS
89
+ # The default arguments to pass to jetty.
90
+ #
91
+ # JETTY_USER
92
+ # if set, then used as a username to run the server as
93
+ #
94
+ # Set to 0 if you do not want to use start-stop-daemon (especially on SUSE boxes)
95
+ START_STOP_DAEMON=1
96
+
97
+ usage()
98
+ {
99
+ echo "Usage: $0 {start|stop|run|restart|check|supervise} [ CONFIGS ... ] "
100
+ exit 1
101
+ }
102
+
103
+ [ $# -gt 0 ] || usage
104
+
105
+
106
+ ##################################################
107
+ # Some utility functions
108
+ ##################################################
109
+ findDirectory()
110
+ {
111
+ OP=$1
112
+ shift
113
+ for L in $* ; do
114
+ [ $OP $L ] || continue
115
+ echo $L
116
+ break
117
+ done
118
+ }
119
+
120
+ running()
121
+ {
122
+ [ -f $1 ] || return 1
123
+ PID=$(cat $1)
124
+ ps -p $PID >/dev/null 2>/dev/null || return 1
125
+ return 0
126
+ }
127
+
128
+ ##################################################
129
+ # Get the action & configs
130
+ ##################################################
131
+
132
+ ACTION=$1
133
+ shift
134
+ ARGS="$*"
135
+ NO_START=0
136
+
137
+ ##################################################
138
+ # See if there's a default configuration file
139
+ ##################################################
140
+ if [ -f /etc/default/jetty7 ] ; then
141
+ . /etc/default/jetty7
142
+ elif [ -f /etc/default/jetty ] ; then
143
+ . /etc/default/jetty
144
+ fi
145
+
146
+
147
+ ##################################################
148
+ # See if there's a user-specific configuration file
149
+ ##################################################
150
+ if [ -f $HOME/.jettyrc ] ; then
151
+ . $HOME/.jettyrc
152
+ fi
153
+
154
+ ##################################################
155
+ # Set tmp if not already set.
156
+ ##################################################
157
+
158
+ if [ -z "$TMP" ]
159
+ then
160
+ TMP=/tmp
161
+ fi
162
+
163
+ ##################################################
164
+ # Jetty's hallmark
165
+ ##################################################
166
+ JETTY_INSTALL_TRACE_FILE="etc/jetty.xml"
167
+ TMPJ=$TMP/j$$
168
+
169
+
170
+ ##################################################
171
+ # Try to determine JETTY_HOME if not set
172
+ ##################################################
173
+ if [ -z "$JETTY_HOME" ]
174
+ then
175
+ JETTY_HOME_1=`dirname "$0"`
176
+ JETTY_HOME_1=`dirname "$JETTY_HOME_1"`
177
+ if [ -f "${JETTY_HOME_1}/${JETTY_INSTALL_TRACE_FILE}" ] ;
178
+ then
179
+ JETTY_HOME=${JETTY_HOME_1}
180
+ fi
181
+ fi
182
+
183
+
184
+ ##################################################
185
+ # if no JETTY_HOME, search likely locations.
186
+ ##################################################
187
+ if [ "$JETTY_HOME" = "" ] ; then
188
+ STANDARD_LOCATIONS=" \
189
+ /usr/share \
190
+ /usr/share/java \
191
+ $HOME \
192
+ $HOME/src \
193
+ ${HOME}/opt/ \
194
+ /opt \
195
+ /java \
196
+ /usr/local \
197
+ /usr/local/share \
198
+ /usr/local/share/java \
199
+ /home \
200
+ "
201
+ JETTY_DIR_NAMES=" \
202
+ jetty-7 \
203
+ jetty7 \
204
+ jetty-7.* \
205
+ jetty \
206
+ Jetty-7 \
207
+ Jetty7 \
208
+ Jetty-7.* \
209
+ Jetty \
210
+ "
211
+
212
+ JETTY_HOME=
213
+ for L in $STANDARD_LOCATIONS
214
+ do
215
+ for N in $JETTY_DIR_NAMES
216
+ do
217
+ if [ -d $L/$N ] && [ -f "$L/${N}/${JETTY_INSTALL_TRACE_FILE}" ] ;
218
+ then
219
+ JETTY_HOME="$L/$N"
220
+ fi
221
+ done
222
+ [ ! -z "$JETTY_HOME" ] && break
223
+ done
224
+ fi
225
+
226
+
227
+ ##################################################
228
+ # No JETTY_HOME yet? We're out of luck!
229
+ ##################################################
230
+ if [ -z "$JETTY_HOME" ] ; then
231
+ echo "** ERROR: JETTY_HOME not set, you need to set it or install in a standard location"
232
+ exit 1
233
+ fi
234
+
235
+ cd $JETTY_HOME
236
+ JETTY_HOME=`pwd`
237
+
238
+ #####################################################
239
+ # Check that jetty is where we think it is
240
+ #####################################################
241
+ if [ ! -r $JETTY_HOME/$JETTY_INSTALL_TRACE_FILE ]
242
+ then
243
+ echo "** ERROR: Oops! Jetty doesn't appear to be installed in $JETTY_HOME"
244
+ echo "** ERROR: $JETTY_HOME/$JETTY_INSTALL_TRACE_FILE is not readable!"
245
+ exit 1
246
+ fi
247
+
248
+ ##################################################
249
+ # Try to find this script's configuration file,
250
+ # but only if no configurations were given on the
251
+ # command line.
252
+ ##################################################
253
+ if [ -z "$JETTY_CONF" ]
254
+ then
255
+ if [ -f /etc/jetty.conf ]
256
+ then
257
+ JETTY_CONF=/etc/jetty.conf
258
+ elif [ -f "${JETTY_HOME}/etc/jetty.conf" ]
259
+ then
260
+ JETTY_CONF="${JETTY_HOME}/etc/jetty.conf"
261
+ fi
262
+ fi
263
+
264
+ ##################################################
265
+ # Read the configuration file if one exists
266
+ ##################################################
267
+ CONFIG_LINES=
268
+ if [ -f "$JETTY_CONF" ] && [ -r "$JETTY_CONF" ]
269
+ then
270
+ CONFIG_LINES=`cat $JETTY_CONF | grep -v "^[:space:]*#" | tr "\n" " "`
271
+ fi
272
+
273
+ #####################################################
274
+ # Find a location for the pid file
275
+ #####################################################
276
+ if [ -z "$JETTY_RUN" ]
277
+ then
278
+ JETTY_RUN=`findDirectory -w /var/run /usr/var/run /tmp`
279
+ fi
280
+
281
+ #####################################################
282
+ # Find a PID for the pid file
283
+ #####################################################
284
+ if [ -z "$JETTY_PID" ]
285
+ then
286
+ JETTY_PID="$JETTY_RUN/jetty.pid"
287
+ fi
288
+
289
+
290
+ ##################################################
291
+ # Check for JAVA_HOME
292
+ ##################################################
293
+ if [ -z "$JAVA_HOME" ]
294
+ then
295
+ # If a java runtime is not defined, search the following
296
+ # directories for a JVM and sort by version. Use the highest
297
+ # version number.
298
+
299
+ # Java search path
300
+ JAVA_LOCATIONS="\
301
+ /usr/java \
302
+ /usr/bin \
303
+ /usr/local/bin \
304
+ /usr/local/java \
305
+ /usr/local/jdk \
306
+ /usr/local/jre \
307
+ /usr/lib/jvm \
308
+ /opt/java \
309
+ /opt/jdk \
310
+ /opt/jre \
311
+ "
312
+ JAVA_NAMES="java jdk jre"
313
+ for N in $JAVA_NAMES ; do
314
+ for L in $JAVA_LOCATIONS ; do
315
+ [ -d $L ] || continue
316
+ find $L -name "$N" ! -type d | grep -v threads | while read J ; do
317
+ [ -x $J ] || continue
318
+ VERSION=`eval $J -version 2>&1`
319
+ [ $? = 0 ] || continue
320
+ VERSION=`expr "$VERSION" : '.*"\(1.[0-9\.]*\)["_]'`
321
+ [ "$VERSION" = "" ] && continue
322
+ expr $VERSION \< 1.2 >/dev/null && continue
323
+ echo $VERSION:$J
324
+ done
325
+ done
326
+ done | sort | tail -1 > $TMPJ
327
+ JAVA=`cat $TMPJ | cut -d: -f2`
328
+ JVERSION=`cat $TMPJ | cut -d: -f1`
329
+
330
+ JAVA_HOME=`dirname $JAVA`
331
+ while [ ! -z "$JAVA_HOME" -a "$JAVA_HOME" != "/" -a ! -f "$JAVA_HOME/lib/tools.jar" ] ; do
332
+ JAVA_HOME=`dirname $JAVA_HOME`
333
+ done
334
+ [ "$JAVA_HOME" = "" ] && JAVA_HOME=
335
+
336
+ echo "Found JAVA=$JAVA in JAVA_HOME=$JAVA_HOME"
337
+ fi
338
+
339
+
340
+ ##################################################
341
+ # Determine which JVM of version >1.2
342
+ # Try to use JAVA_HOME
343
+ ##################################################
344
+ if [ "$JAVA" = "" -a "$JAVA_HOME" != "" ]
345
+ then
346
+ if [ ! -z "$JAVACMD" ]
347
+ then
348
+ JAVA="$JAVACMD"
349
+ else
350
+ [ -x $JAVA_HOME/bin/jre -a ! -d $JAVA_HOME/bin/jre ] && JAVA=$JAVA_HOME/bin/jre
351
+ [ -x $JAVA_HOME/bin/java -a ! -d $JAVA_HOME/bin/java ] && JAVA=$JAVA_HOME/bin/java
352
+ fi
353
+ fi
354
+
355
+ if [ "$JAVA" = "" ]
356
+ then
357
+ echo "Cannot find a JRE or JDK. Please set JAVA_HOME to a >=1.2 JRE" 2>&2
358
+ exit 1
359
+ fi
360
+
361
+ JAVA_VERSION=`expr "$($JAVA -version 2>&1 | head -1)" : '.*1\.\([0-9]\)'`
362
+
363
+ #####################################################
364
+ # See if JETTY_PORT is defined
365
+ #####################################################
366
+ if [ "$JETTY_PORT" != "" ]
367
+ then
368
+ JAVA_OPTIONS="$JAVA_OPTIONS -Djetty.port=$JETTY_PORT"
369
+ fi
370
+
371
+ #####################################################
372
+ # See if JETTY_LOGS is defined
373
+ #####################################################
374
+ if [ "$JETTY_LOGS" != "" ]
375
+ then
376
+ JAVA_OPTIONS="$JAVA_OPTIONS -Djetty.logs=$JETTY_LOGS"
377
+ fi
378
+
379
+ #####################################################
380
+ # Are we running on Windows? Could be, with Cygwin/NT.
381
+ #####################################################
382
+ case "`uname`" in
383
+ CYGWIN*) PATH_SEPARATOR=";";;
384
+ *) PATH_SEPARATOR=":";;
385
+ esac
386
+
387
+
388
+ #####################################################
389
+ # Add jetty properties to Java VM options.
390
+ #####################################################
391
+ JAVA_OPTIONS="$JAVA_OPTIONS -Djetty.home=$JETTY_HOME -Djava.io.tmpdir=$TMP"
392
+
393
+ [ -f $JETTY_HOME/etc/start.config ] && JAVA_OPTIONS="-DSTART=$JETTY_HOME/etc/start.config $JAVA_OPTIONS"
394
+
395
+ #####################################################
396
+ # This is how the Jetty server will be started
397
+ #####################################################
398
+
399
+ JETTY_START=$JETTY_HOME/start.jar
400
+ [ ! -f $JETTY_START ] && JETTY_START=$JETTY_HOME/lib/start.jar
401
+
402
+ RUN_ARGS="$JAVA_OPTIONS -jar $JETTY_START --fromDaemon $JETTY_ARGS $ARGS"
403
+ RUN_CMD="$JAVA $RUN_ARGS"
404
+
405
+ #####################################################
406
+ # Comment these out after you're happy with what
407
+ # the script is doing.
408
+ #####################################################
409
+ #echo "JETTY_HOME = $JETTY_HOME"
410
+ #echo "JETTY_CONF = $JETTY_CONF"
411
+ #echo "JETTY_RUN = $JETTY_RUN"
412
+ #echo "JETTY_PID = $JETTY_PID"
413
+ #echo "JETTY_ARGS = $JETTY_ARGS"
414
+ #echo "ARGS = $ARGS"
415
+ #echo "JAVA_OPTIONS = $JAVA_OPTIONS"
416
+ #echo "JAVA = $JAVA"
417
+
418
+
419
+ ##################################################
420
+ # Do the action
421
+ ##################################################
422
+ case "$ACTION" in
423
+ start)
424
+ echo -n "Starting Jetty: "
425
+
426
+ if [ "$NO_START" = "1" ]; then
427
+ echo "Not starting jetty - NO_START=1 in /etc/default/jetty7";
428
+ exit 0;
429
+ fi
430
+
431
+
432
+ if [ "$START_STOP_DAEMON" = "1" ] && type start-stop-daemon > /dev/null 2>&1
433
+ then
434
+ [ x$JETTY_USER = x ] && JETTY_USER=$(whoami)
435
+ [ $UID = 0 ] && CH_USER="-c $JETTY_USER"
436
+ if start-stop-daemon -S -p$JETTY_PID $CH_USER -d $JETTY_HOME -b -m -a $JAVA -- $RUN_ARGS
437
+ then
438
+ sleep 1
439
+ if running $JETTY_PID
440
+ then
441
+ echo OK
442
+ else
443
+ echo FAILED
444
+ fi
445
+ fi
446
+
447
+ else
448
+
449
+ if [ -f $JETTY_PID ]
450
+ then
451
+ if running $JETTY_PID
452
+ then
453
+ echo "Already Running!!"
454
+ exit 1
455
+ else
456
+ # dead pid file - remove
457
+ rm -f $JETTY_PID
458
+ fi
459
+ fi
460
+
461
+ if [ x$JETTY_USER != x ]
462
+ then
463
+ touch $JETTY_PID
464
+ chown $JETTY_USER $JETTY_PID
465
+ su - $JETTY_USER -c "
466
+ $RUN_CMD &
467
+ PID=\$!
468
+ disown \$PID
469
+ echo \$PID > $JETTY_PID"
470
+ else
471
+ $RUN_CMD &
472
+ PID=$!
473
+ disown $PID
474
+ echo $PID > $JETTY_PID
475
+ fi
476
+
477
+ echo "STARTED Jetty `date`"
478
+ fi
479
+
480
+ ;;
481
+
482
+ stop)
483
+ echo -n "Stopping Jetty: "
484
+ if [ "$START_STOP_DAEMON" = "1" ] && type start-stop-daemon > /dev/null 2>&1; then
485
+ start-stop-daemon -K -p $JETTY_PID -d $JETTY_HOME -a $JAVA -s HUP
486
+ sleep 1
487
+ if running $JETTY_PID
488
+ then
489
+ sleep 3
490
+ if running $JETTY_PID
491
+ then
492
+ sleep 30
493
+ if running $JETTY_PID
494
+ then
495
+ start-stop-daemon -K -p $JETTY_PID -d $JETTY_HOME -a $JAVA -s KILL
496
+ fi
497
+ fi
498
+ fi
499
+
500
+ rm -f $JETTY_PID
501
+ echo OK
502
+ else
503
+ PID=`cat $JETTY_PID 2>/dev/null`
504
+ TIMEOUT=30
505
+ while running $JETTY_PID && [ $TIMEOUT -gt 0 ]
506
+ do
507
+ kill $PID 2>/dev/null
508
+ sleep 1
509
+ let TIMEOUT=$TIMEOUT-1
510
+ done
511
+
512
+ [ $TIMEOUT -gt 0 ] || kill -9 $PID 2>/dev/null
513
+
514
+ rm -f $JETTY_PID
515
+ echo OK
516
+ fi
517
+ ;;
518
+
519
+ restart)
520
+ JETTY_SH=$0
521
+ if [ ! -f $JETTY_SH ]; then
522
+ if [ ! -f $JETTY_HOME/bin/jetty.sh ]; then
523
+ echo "$JETTY_HOME/bin/jetty.sh does not exist."
524
+ exit 1
525
+ fi
526
+ JETTY_SH=$JETTY_HOME/bin/jetty.sh
527
+ fi
528
+ $JETTY_SH stop $*
529
+ sleep 5
530
+ $JETTY_SH start $*
531
+ ;;
532
+
533
+ supervise)
534
+ #
535
+ # Under control of daemontools supervise monitor which
536
+ # handles restarts and shutdowns via the svc program.
537
+ #
538
+ exec $RUN_CMD
539
+ ;;
540
+
541
+ run|demo)
542
+ echo "Running Jetty: "
543
+
544
+ if [ -f $JETTY_PID ]
545
+ then
546
+ if running $JETTY_PID
547
+ then
548
+ echo "Already Running!!"
549
+ exit 1
550
+ else
551
+ # dead pid file - remove
552
+ rm -f $JETTY_PID
553
+ fi
554
+ fi
555
+
556
+ exec $RUN_CMD
557
+ ;;
558
+
559
+ check)
560
+ echo "Checking arguments to Jetty: "
561
+ echo "JETTY_HOME = $JETTY_HOME"
562
+ echo "JETTY_CONF = $JETTY_CONF"
563
+ echo "JETTY_RUN = $JETTY_RUN"
564
+ echo "JETTY_PID = $JETTY_PID"
565
+ echo "JETTY_PORT = $JETTY_PORT"
566
+ echo "JETTY_LOGS = $JETTY_LOGS"
567
+ echo "JAVA_OPTIONS = $JAVA_OPTIONS"
568
+ echo "JAVA = $JAVA"
569
+ echo "CLASSPATH = $CLASSPATH"
570
+ echo "RUN_CMD = $RUN_CMD"
571
+ echo
572
+
573
+ if [ -f $JETTY_RUN/jetty.pid ]
574
+ then
575
+ echo "Jetty running pid="`cat $JETTY_RUN/jetty.pid`
576
+ exit 0
577
+ fi
578
+ exit 1
579
+ ;;
580
+
581
+ *)
582
+ usage
583
+ ;;
584
+ esac
585
+
586
+ exit 0
587
+
588
+
589
+
@@ -3,6 +3,8 @@ jetty_prefix: /opt
3
3
  jetty_dir: "#{jetty_prefix}/jetty"
4
4
  jetty_port: 8080
5
5
 
6
+ jetty_jvm_options: -XX:MaxPermSize=128m
7
+
6
8
  roles:
7
9
  jetty:
8
10
  packages: [openjdk-6-jdk]
@@ -32,6 +32,7 @@ role_dependencies:
32
32
  db: [mysql_slave]
33
33
 
34
34
  packages: [mysql-client, libmysql-ruby]
35
+ gems: [mysql]
35
36
 
36
37
  roles:
37
38
  mysql_master:
@@ -1,4 +1,4 @@
1
- passenger_version: 2.2.8
1
+ passenger_version: 2.2.9
2
2
  passenger_root: "#{ruby_prefix}/lib/ruby/gems/1.8/gems/passenger-#{passenger_version}"
3
3
  passenger_ruby: "#{ruby_prefix}/bin/ruby"
4
4
  passenger_lib: "#{passenger_root}/ext/apache2/mod_passenger.so"
@@ -8,7 +8,7 @@ namespace :rubber do
8
8
  after "rubber:install_packages", "rubber:redis:custom_install"
9
9
 
10
10
  task :custom_install, :roles => :redis do
11
- custom_package('http://ftp.us.debian.org/debian/pool/main/r/redis/', 'redis-server', '1.02-1', '! -x /usr/bin/redis-server')
11
+ custom_package('http://ftp.us.debian.org/debian/pool/main/r/redis/', 'redis-server', '1.2.0-1', '! -x /usr/bin/redis-server')
12
12
  end
13
13
 
14
14
  desc "Stops the redis server"
@@ -15,13 +15,18 @@ module Rubber
15
15
  AWS::S3::Base.establish_connection!(:access_key_id => @aws_env.access_key, :secret_access_key => @aws_env.secret_access_key)
16
16
  end
17
17
 
18
-
19
18
  def create_instance(ami, ami_type, security_groups, availability_zone)
20
19
  response = @ec2.run_instances(:image_id => ami, :key_name => @aws_env.key_name, :instance_type => ami_type, :security_group => security_groups, :availability_zone => availability_zone)
21
20
  instance_id = response.instancesSet.item[0].instanceId
22
21
  return instance_id
23
22
  end
24
23
 
24
+ def create_spot_instance_request(spot_price, ami, ami_type, security_groups, availability_zone)
25
+ response = @ec2.request_spot_instances(:spot_price => spot_price, :image_id => ami, :key_name => @aws_env.key_name, :instance_type => ami_type, :security_group => security_groups, :availability_zone => availability_zone)
26
+ request_id = response.spotInstanceRequestSet.item[0].spotInstanceRequestId
27
+ return request_id
28
+ end
29
+
25
30
  def describe_instances(instance_id=nil)
26
31
  instances = []
27
32
  opts = {}
@@ -37,6 +42,7 @@ module Rubber
37
42
  instance[:internal_host] = item.privateDnsName
38
43
  instance[:state] = item.instanceState.name
39
44
  instance[:zone] = item.placement.availabilityZone
45
+ instance[:platform] = item.platform || 'linux'
40
46
  instances << instance
41
47
  end
42
48
  end if response.reservationSet
@@ -271,6 +277,10 @@ module Rubber
271
277
  end
272
278
  end
273
279
 
280
+ def destroy_spot_instance_request(request_id)
281
+ @ec2.cancel_spot_instance_requests :spot_instance_request_id => request_id
282
+ end
283
+
274
284
  def describe_load_balancers(name=nil)
275
285
  lbs = []
276
286
  opts = {}
@@ -300,6 +310,25 @@ module Rubber
300
310
  return lbs
301
311
  end
302
312
 
313
+ def describe_spot_instance_requests(request_id=nil)
314
+ requests = []
315
+ opts = {}
316
+ opts[:spot_instance_request_id] = request_id if request_id
317
+ response = @ec2.describe_spot_instance_requests(opts)
318
+ response.spotInstanceRequestSet.item.each do |item|
319
+ request = {}
320
+ request[:id] = item.spotInstanceRequestId
321
+ request[:spot_price] = item.spotPrice
322
+ request[:state] = item.state
323
+ request[:created_at] = item.createTime
324
+ request[:type] = item.launchSpecification.instanceType
325
+ request[:image_id] = item.launchSpecification.imageId
326
+ request[:instance_id] = item.instanceId
327
+ requests << request
328
+ end if response.spotInstanceRequestSet
329
+ return requests
330
+ end
331
+
303
332
  end
304
333
 
305
334
  end
@@ -81,6 +81,8 @@ module Rubber
81
81
  attr_accessor :external_host, :external_ip
82
82
  attr_accessor :internal_host, :internal_ip
83
83
  attr_accessor :static_ip, :volumes, :partitions
84
+ attr_accessor :spot_instance_request_id
85
+ attr_accessor :platform
84
86
 
85
87
  def initialize(name, domain, roles, instance_id, security_group_list=[])
86
88
  @name = name
@@ -97,6 +99,15 @@ module Rubber
97
99
  def role_names()
98
100
  roles.collect {|r| r.name}
99
101
  end
102
+
103
+ def platform
104
+ # Deal with old instance configurations that don't have a platform value persisted.
105
+ @platform || 'linux'
106
+ end
107
+
108
+ def windows?
109
+ platform == 'windows'
110
+ end
100
111
  end
101
112
 
102
113
  # The configuration for a single role contained in the list
@@ -10,7 +10,13 @@ require 'rubber'
10
10
 
11
11
  namespace :rubber do
12
12
 
13
- # advise capistrano's task method so that tasks for non-existant roles don't
13
+ # Disable connecting to any Windows instance.
14
+ alias :original_task :task
15
+ def task(name, options={}, &block)
16
+ original_task(name, options.merge(:except => { :platform => 'windows' }), &block)
17
+ end
18
+
19
+ # advise capistrano's task method so that tasks for non-existent roles don't
14
20
  # fail when roles isn't defined due to using a FILTER for load_roles
15
21
  # If you have a task you need to execute even when there are no
16
22
  # roles, you have to use required_task instead of task - see rubber:create
@@ -19,7 +25,8 @@ namespace :rubber do
19
25
  class << ns
20
26
  alias :required_task :task
21
27
  def task(name, options={}, &block)
22
- required_task(name, options) do
28
+ # Disable connecting to any Windows instance.
29
+ required_task(name, options.merge(:except => { :platform => 'windows' })) do
23
30
  # define empty roles for the case when a task has a role that we don't define anywhere
24
31
  [*options[:roles]].each do |r|
25
32
  roles[r] ||= []
@@ -73,7 +80,7 @@ namespace :rubber do
73
80
  # define capistrano host => role mapping for all instances
74
81
  rubber_instances.filtered.each do |ic|
75
82
  ic.roles.each do |role|
76
- opts = Rubber::Util::symbolize_keys(role.options)
83
+ opts = Rubber::Util::symbolize_keys(role.options).merge(:platform => ic.platform)
77
84
  msg = "Auto role: #{role.name.to_sym} => #{ic.full_name}"
78
85
  msg << ", #{opts.inspect}" if opts.inspect.size > 0
79
86
  logger.info msg
@@ -10,6 +10,8 @@ namespace :rubber do
10
10
  default_roles = env.instance_roles
11
11
  r = get_env("ROLES", "Instance roles (e.g. web,app,db:primary=true)", true, default_roles)
12
12
 
13
+ create_spot_instance = ENV.delete("SPOT_INSTANCE") || env.cloud_providers[env.cloud_provider].spot_instance
14
+
13
15
  if r == '*'
14
16
  instance_roles = rubber_cfg.environment.known_roles
15
17
  instance_roles = instance_roles.collect {|role| role == "db" ? "db:primary=true" : role }
@@ -33,7 +35,7 @@ namespace :rubber do
33
35
  # Add in roles that the given set of roles depends on
34
36
  ir = Rubber::Configuration::RoleItem.expand_role_dependencies(ir, get_role_dependencies)
35
37
 
36
- create_instance(instance_alias, ir)
38
+ create_instance(instance_alias, ir, create_spot_instance)
37
39
  end
38
40
 
39
41
  desc <<-DESC
@@ -154,7 +156,7 @@ namespace :rubber do
154
156
 
155
157
  # Creates a new ec2 instance with the given alias and roles
156
158
  # Configures aliases (/etc/hosts) on local and remote machines
157
- def create_instance(instance_alias, instance_roles)
159
+ def create_instance(instance_alias, instance_roles, create_spot_instance=false)
158
160
  fatal "Instance already exists: #{instance_alias}" if rubber_instances[instance_alias]
159
161
 
160
162
  role_names = instance_roles.collect{|x| x.name}
@@ -167,12 +169,45 @@ namespace :rubber do
167
169
  ami = env.cloud_providers[env.cloud_provider].image_id
168
170
  ami_type = env.cloud_providers[env.cloud_provider].image_type
169
171
  availability_zone = env.availability_zone
170
- logger.info "Creating instance #{ami}/#{ami_type}/#{security_groups.join(',') rescue 'Default'}/#{availability_zone || 'Default'}"
171
- instance_id = cloud.create_instance(ami, ami_type, security_groups, availability_zone)
172
+
173
+ if create_spot_instance
174
+ spot_price = env.cloud_providers[env.cloud_provider].spot_price.to_s
175
+
176
+ logger.info "Creating spot instance request for instance #{ami}/#{ami_type}/#{security_groups.join(',') rescue 'Default'}/#{availability_zone || 'Default'}"
177
+ request_id = cloud.create_spot_instance_request(spot_price, ami, ami_type, security_groups, availability_zone)
178
+
179
+ print "Waiting for spot instance request to be fulfilled"
180
+ max_wait_time = env.cloud_providers[env.cloud_provider].spot_instance_request_timeout || (1.0 / 0) # Use the specified timeout value or default to infinite.
181
+ instance_id = nil
182
+ while instance_id.nil? do
183
+ print "."
184
+ sleep 2
185
+ max_wait_time -= 2
186
+
187
+ request = cloud.describe_spot_instance_requests(request_id).first
188
+ instance_id = request[:instance_id]
189
+
190
+ if max_wait_time < 0 && instance_id.nil?
191
+ cloud.destroy_spot_instance_request(request[:id])
192
+
193
+ print "\n"
194
+ print "Failed to fulfill spot instance in the time specified. Falling back to on-demand instance creation."
195
+ break
196
+ end
197
+ end
198
+
199
+ print "\n"
200
+ end
201
+
202
+ if !create_spot_instance || (create_spot_instance && max_wait_time < 0)
203
+ logger.info "Creating instance #{ami}/#{ami_type}/#{security_groups.join(',') rescue 'Default'}/#{availability_zone || 'Default'}"
204
+ instance_id = cloud.create_instance(ami, ami_type, security_groups, availability_zone)
205
+ end
172
206
 
173
207
  logger.info "Instance #{instance_id} created"
174
208
 
175
209
  instance_item = Rubber::Configuration::InstanceItem.new(instance_alias, env.domain, instance_roles, instance_id, security_groups)
210
+ instance_item.spot_instance_request_id = request_id if create_spot_instance
176
211
  rubber_instances.add(instance_item)
177
212
  rubber_instances.save()
178
213
 
@@ -190,6 +225,7 @@ namespace :rubber do
190
225
  instance_item.external_ip = instance[:external_ip]
191
226
  instance_item.internal_host = instance[:internal_host]
192
227
  instance_item.zone = instance[:zone]
228
+ instance_item.platform = instance[:platform]
193
229
  rubber_instances.save()
194
230
 
195
231
  # setup amazon elastic ips if configured to do so
@@ -206,7 +242,14 @@ namespace :rubber do
206
242
  # so that we can update all aliases
207
243
 
208
244
  task :_get_ip, :hosts => instance_item.external_ip do
209
- instance_item.internal_ip = capture(print_ip_command).strip
245
+ # There's no good way to get the internal IP for a Windows host, so just set it to the external
246
+ # and let the router handle mapping to the internal network.
247
+ if instance_item.windows?
248
+ instance_item.internal_ip = instance_item.external_ip
249
+ else
250
+ instance_item.internal_ip = capture(print_ip_command).strip
251
+ end
252
+
210
253
  rubber_instances.save()
211
254
  end
212
255
 
@@ -1,5 +1,8 @@
1
1
  namespace :rubber do
2
2
 
3
+ # Disable connecting to any Windows instance.
4
+ set :default_run_options, :except => { :platform => 'windows' }
5
+
3
6
  desc <<-DESC
4
7
  Bootstraps instances by setting timezone, installing packages and gems
5
8
  DESC
@@ -0,0 +1,23 @@
1
+ namespace :rubber do
2
+
3
+ desc "Describes all your spot instance requests"
4
+ required_task :describe_spot_instance_requests do
5
+ requests = cloud.describe_spot_instance_requests()
6
+ requests.each do |request|
7
+ logger.info "======================"
8
+ logger.info "ID: #{request[:id]}"
9
+ logger.info "Created at: #{request[:created_at]}"
10
+ logger.info "Max. price: $#{request[:spot_price]}"
11
+ logger.info "State: #{request[:state]}"
12
+ logger.info "Instance type: #{request[:type]}"
13
+ logger.info "AMI: #{request[:image_id]}"
14
+ end
15
+ end
16
+
17
+ desc "Cancel the spot instances request for the given id"
18
+ required_task :cancel_spot_instances_request do
19
+ request_id = get_env('SPOT_INSTANCE_REQUEST_ID', 'The id of the spot instances request to cancel', true)
20
+ cloud.destroy_spot_instance_request(request_id)
21
+ end
22
+
23
+ end
@@ -80,6 +80,89 @@ namespace :rubber do
80
80
  destroy_static_ip(ip)
81
81
  end
82
82
 
83
+ desc 'Move a static IP address from DONOR machine to RECEIVER machine.'
84
+ task :move_static_ip do
85
+ donor_alias = get_env 'DONOR', 'Instance alias to get the IP from (e.g., web01)', true
86
+ receiver_alias = get_env 'RECEIVER', 'Instance alias to assign the IP to (e.g., web02)', true
87
+
88
+ # Sanity checks
89
+ donor = rubber_instances[donor_alias]
90
+ fatal "Instance does not exist: #{donor_alias}" unless donor
91
+
92
+ static_ip = donor.static_ip
93
+ fatal 'No static IP address to move exists' unless static_ip && static_ip != ''
94
+
95
+ receiver = rubber_instances[receiver_alias]
96
+ fatal "Instance does not exist: #{receiver_alias}" unless receiver
97
+
98
+ # Temporary removal of the instances.
99
+ old_donor = rubber_instances.remove(donor_alias)
100
+ old_receiver = rubber_instances.remove(receiver_alias)
101
+
102
+ rubber_instances.save
103
+
104
+ # Getting rid of alias->IP mappings and SSH's known_hosts records.
105
+ load_roles
106
+ setup_aliases
107
+ cleanup_known_hosts(old_donor)
108
+ cleanup_known_hosts(old_receiver)
109
+
110
+ # Detachment of EIPA.
111
+ success = cloud.detach_static_ip(static_ip)
112
+ fatal "Failed to detach static IP address #{static_ip}" unless success
113
+ rubber_instances.artifacts['static_ips'].delete(old_donor.name)
114
+
115
+ rubber_instances.save
116
+
117
+ # Attachment of EIPA.
118
+ success = cloud.attach_static_ip(static_ip, old_receiver.instance_id)
119
+ fatal "Failed to associate static IP address #{static_ip}" unless success
120
+
121
+ print "Waiting for #{receiver_alias} to get the address"
122
+ while true do
123
+ print '.'
124
+ sleep 3
125
+ instance = cloud.describe_instances(old_receiver.instance_id).first
126
+ break if instance[:external_ip] == static_ip
127
+ end
128
+
129
+ # Partial cleanup of static IP records.
130
+ rubber_instances.artifacts['static_ips'][old_receiver.name] = static_ip
131
+
132
+ rubber_instances.save
133
+
134
+ # First half of the sync.
135
+ new_receiver = Rubber::Configuration::InstanceItem.new(old_receiver.name,
136
+ old_receiver.domain, old_receiver.roles, old_receiver.instance_id,
137
+ old_receiver.security_groups)
138
+ new_receiver.static_ip = static_ip
139
+ rubber_instances.add(new_receiver)
140
+
141
+ rubber_instances.save
142
+
143
+ refresh_instance(receiver_alias)
144
+
145
+ print "Waiting for #{donor_alias} to get a new address"
146
+ while true do
147
+ print '.'
148
+ sleep 3
149
+ instance = cloud.describe_instances(old_donor.instance_id).first
150
+ break if instance[:external_ip] && instance[:external_ip] != ''
151
+ end
152
+
153
+ # Second half of the sync.
154
+ new_donor = Rubber::Configuration::InstanceItem.new(old_donor.name,
155
+ old_donor.domain, old_donor.roles, old_donor.instance_id,
156
+ old_donor.security_groups)
157
+ rubber_instances.add(new_donor)
158
+
159
+ rubber_instances.save
160
+
161
+ refresh_instance(donor_alias)
162
+
163
+ logger.info "Run 'cap rubber:describe_static_ips' to check the allocated ones"
164
+ end
165
+
83
166
  def allocate_static_ip()
84
167
  ip = cloud.create_static_ip()
85
168
  fatal "Failed to allocate static ip" if ip.nil?
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ gem 'test-unit'
3
+
1
4
  require 'test/unit'
2
5
  require 'tempfile'
3
6
  require 'test_helper'
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ gem 'test-unit'
3
+
1
4
  require 'test/unit'
2
5
  require 'tempfile'
3
6
  require 'test_helper'
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ gem 'test-unit'
3
+
1
4
  require 'test/unit'
2
5
  require 'tempfile'
3
6
  require 'test_helper'
data/test/util_test.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ gem 'test-unit'
3
+
1
4
  require 'test/unit'
2
5
  require 'test_helper'
3
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubber
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-22 00:00:00 -05:00
12
+ date: 2010-01-22 00:00:00 -05:00
13
13
  default_executable: vulcanize
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.8
33
+ version: 0.9.0
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: aws-s3
@@ -80,6 +80,7 @@ extensions: []
80
80
 
81
81
  extra_rdoc_files:
82
82
  - README
83
+ - TODO
83
84
  files:
84
85
  - CHANGELOG
85
86
  - COPYING
@@ -138,6 +139,7 @@ files:
138
139
  - generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml
139
140
  - generators/vulcanize/templates/haproxy/templates.yml
140
141
  - generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb
142
+ - generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.sh
141
143
  - generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.xml
142
144
  - generators/vulcanize/templates/jetty/config/rubber/role/jetty/monit-jetty.conf
143
145
  - generators/vulcanize/templates/jetty/config/rubber/rubber-jetty.yml
@@ -253,6 +255,7 @@ files:
253
255
  - lib/rubber/recipes/rubber/load_balancers.rb
254
256
  - lib/rubber/recipes/rubber/security_groups.rb
255
257
  - lib/rubber/recipes/rubber/setup.rb
258
+ - lib/rubber/recipes/rubber/spot_requests.rb
256
259
  - lib/rubber/recipes/rubber/static_ips.rb
257
260
  - lib/rubber/recipes/rubber/utils.rb
258
261
  - lib/rubber/recipes/rubber/volumes.rb