ec2launcher 1.0.31 → 1.0.32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.32
2
+
3
+ * Copied Alestic's runurl script to avoid problems with LaunchPad is down. Switched to using ec2launcher's copy of runurl.
4
+
1
5
  ## 1.0.31
2
6
 
3
7
  * Added support for pre/post commands to applications. Useful for installing webapps.
data/lib/ec2launcher.rb CHANGED
@@ -399,7 +399,7 @@ module EC2Launcher
399
399
  # ELB
400
400
  ##############################
401
401
  unless elb_name.nil?
402
- instances.each {|instance| attach_to_elb(instance, elb_name) }
402
+ instances.each {|instance| attach_to_elb(instance, elb_name, ec2_subnet) }
403
403
  end
404
404
 
405
405
  ##############################
@@ -412,34 +412,37 @@ module EC2Launcher
412
412
  #
413
413
  # @param [AWS::EC2::Instance] instance newly created EC2 instance.
414
414
  # @param [String] elb_name name of ELB.
415
+ # @param [String] subnet subnet name or id. Defaults to nil.
415
416
  #
416
- def attach_to_elb(instance, elb_name)
417
+ def attach_to_elb(instance, elb_name, subnet = nil)
417
418
  begin
418
419
  @log.info ""
419
420
  @log.info "Adding to ELB: #{elb_name}"
420
421
  elb = AWS::ELB.new
421
422
  AWS.memoize do
422
- # Build list of availability zones for any existing instances
423
- zones = { }
424
- zones[instance.availability_zone] = instance.availability_zone
425
- elb.load_balancers[elb_name].instances.each do |elb_instance|
426
- zones[elb_instance.availability_zone] = elb_instance.availability_zone
427
- end
428
-
429
- # Build list of existing zones
430
- existing_zones = { }
431
- elb.load_balancers[elb_name].availability_zones.each do |zone|
432
- existing_zones[zone.name] = zone
433
- end
434
-
435
- # Enable zones
436
- zones.keys.each do |zone_name|
437
- elb.load_balancers[elb_name].availability_zones.enable(zones[zone_name])
438
- end
439
-
440
- # Disable zones
441
- existing_zones.keys.each do |zone_name|
442
- elb.load_balancers[elb_name].availability_zones.disable(existing_zones[zone_name]) unless zones.has_key?(zone_name)
423
+ unless subnet
424
+ # Build list of availability zones for any existing instances
425
+ zones = { }
426
+ zones[instance.availability_zone] = instance.availability_zone
427
+ elb.load_balancers[elb_name].instances.each do |elb_instance|
428
+ zones[elb_instance.availability_zone] = elb_instance.availability_zone
429
+ end
430
+
431
+ # Build list of existing zones
432
+ existing_zones = { }
433
+ elb.load_balancers[elb_name].availability_zones.each do |zone|
434
+ existing_zones[zone.name] = zone
435
+ end
436
+
437
+ # Enable zones
438
+ zones.keys.each do |zone_name|
439
+ elb.load_balancers[elb_name].availability_zones.enable(zones[zone_name])
440
+ end
441
+
442
+ # Disable zones
443
+ existing_zones.keys.each do |zone_name|
444
+ elb.load_balancers[elb_name].availability_zones.disable(existing_zones[zone_name]) unless zones.has_key?(zone_name)
445
+ end
443
446
  end
444
447
 
445
448
  elb.load_balancers[elb_name].instances.register(instance)
@@ -7,6 +7,6 @@ module EC2Launcher
7
7
  AVAILABILITY_ZONES = %w{us-east-1a us-east-1b us-east-1c us-east-1d}
8
8
  INSTANCE_TYPES = %w{m1.small m1.medium m1.large m1.xlarge t1.micro m2.xlarge m2.2xlarge m2.4xlarge c1.medium c1.xlarge cc1.4xlarge cg1.4xlarge}
9
9
 
10
- RUN_URL_SCRIPT = "http://bazaar.launchpad.net/~alestic/runurl/trunk/download/head:/runurl-20090817053347-o2e56z7xwq8m9tt6-1/runurl"
10
+ RUN_URL_SCRIPT = "https://raw.github.com/StudyBlue/ec2launcher/master/startup-scripts/runurl"
11
11
  SETUP_SCRIPT = "https://raw.github.com/StudyBlue/ec2launcher/master/startup-scripts/setup.rb"
12
12
  end
@@ -2,5 +2,5 @@
2
2
  # Copyright (c) 2012 Sean Laurent
3
3
  #
4
4
  module EC2Launcher
5
- VERSION = "1.0.31"
5
+ VERSION = "1.0.32"
6
6
  end
@@ -0,0 +1,206 @@
1
+ #!/bin/sh
2
+ #
3
+ # runurl - Download a URL and run as a program, passing in arguments
4
+ #
5
+ # Copyright (C) 2009 Eric Hammond <ehammond@thinksome.com>
6
+ #
7
+
8
+ error() { echo "$@" 1>&2; }
9
+ fail() { [ $# -eq 0 ] || error "${BNAME}:" "$1"; exit ${2:-1}; }
10
+ debug() { [ "$DEBUG" = "0" ] || error "${BNAME}:" "$@"; }
11
+ cleanup() { [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"; }
12
+
13
+ DEBUG="0"
14
+ TEMP_D=""
15
+ BNAME=${0##*/}
16
+
17
+ while [ $# -gt 0 ]; do
18
+ case $1 in
19
+ -\?|--help) pod2text "${0}"; exit 0;;
20
+ -d|--debug) DEBUG=1; shift 1 ;;
21
+ -*) fail "Unrecognized option: $1 (try --help)";;
22
+ *) url="$1"; shift 1; break ;;
23
+ esac
24
+ done
25
+
26
+ [ -n "$url" ] || fail "Missing URL specification (try --help)"
27
+
28
+ trap cleanup 0
29
+
30
+ TEMP_D=$(mktemp -d ${TEMPDIR:-/tmp}/${BNAME}.XXXXXX) &&
31
+ runfile="${TEMP_D}/runfile" && wgetfile="${TEMP_D}/wget.out" ||
32
+ fail "failed to make tempdir"
33
+
34
+ debug "downloading $url"
35
+
36
+ wget \
37
+ --retry-connrefused \
38
+ --tries=20 \
39
+ "--output-document=$runfile" \
40
+ "--output-file=$wgetfile" \
41
+ "$url"
42
+
43
+ wgetstatus=$?
44
+ if [ $wgetstatus != 0 ]; then
45
+ cat $wgetfile >&2
46
+ fail "wget failed: $wgetstatus" "${wgetstatus}"
47
+ fi
48
+
49
+ chmod 700 "${runfile}" || fail "failed to change perms of ${runfile}"
50
+
51
+ debug "running"
52
+ $runfile "$@"
53
+
54
+ exitstatus=$?
55
+
56
+ debug "exit status $exitstatus"
57
+
58
+ exit $exitstatus
59
+
60
+ #
61
+ # To read the documentation in this file use the command:
62
+ #
63
+ # perldoc runurl
64
+ #
65
+
66
+ =head1 NAME
67
+
68
+ runurl - Download a URL and run as a program, passing in arguments
69
+
70
+ =head1 SYNOPSYS
71
+
72
+ runurl [I<OPTS>] I<URL> [I<ARGS>]...
73
+
74
+ =head1 OPTIONS
75
+
76
+ =over 8
77
+
78
+ =item B<-?> B<--help>
79
+
80
+ Debug mode
81
+
82
+ =item B<-d> B<--debug>
83
+
84
+ Debug mode
85
+
86
+ =back
87
+
88
+ =head1 ARGUMENTS
89
+
90
+ =over 8
91
+
92
+ =item B<URL>
93
+
94
+ The URL of the progran to download and run
95
+
96
+ =item B<ARGS>
97
+
98
+ Options and arguments for the downloaded program
99
+
100
+ =back
101
+
102
+ =head1 DESCRIPTION
103
+
104
+ The B<runurl> command is a simple tool that downloads a program (or
105
+ script) from the specified URL and runs it.
106
+
107
+ The first argument to the B<runurl> command is the URL of a script or
108
+ program that should be run. Any leading "http://" may be omitted, but
109
+ "https://" or "ftp://" and the like must still be specified.
110
+
111
+ All remaining arguments listed after the URL (including ones which
112
+ look like options) are passed verbatim to the program as its own
113
+ options and arguments when it is run.
114
+
115
+ The exit code of B<runurl> is the exit code of the program, unless the
116
+ original download of the URL failed, in which case that error is
117
+ returned.
118
+
119
+ =head1 EXAMPLES
120
+
121
+ If the following content is stored at http://run.alestic.com/demo/hello
122
+
123
+ #!/bin/bash
124
+ echo "hello, $1"
125
+
126
+ then this command:
127
+
128
+ runurl run.alestic.com/demo/hello world
129
+
130
+ will itself output:
131
+
132
+ hello, world
133
+
134
+ =head1 CAVEATS
135
+
136
+ Only run content that you control or completely trust.
137
+
138
+ Just because you like the content of a URL when you look at it in your
139
+ browser does not mean that it will still look like that when B<runurl>
140
+ goes to run it. It could change at any point to something that is
141
+ broken or even malicious unless it is under your control.
142
+
143
+ Realize that you are depending on the network for commands to succeed.
144
+ If the content is temporarily unavailable or has been moved, then the
145
+ B<runurl> command will fail.
146
+
147
+ =head1 DEPENDENCIES
148
+
149
+ This program requires that the following already be installed:
150
+
151
+ wget
152
+
153
+ =head1 SEE ALSO
154
+
155
+ The B<runurl> project site:
156
+
157
+ https://launchpad.net/runurl
158
+
159
+ Article about using B<runurl> for initial configuration of Amazon EC2
160
+ instances:
161
+
162
+ http://alestic.com/2009/08/runurl
163
+
164
+ =head1 INSTALLATION
165
+
166
+ On most Ubuntu releases, the B<runurl> package can be installed
167
+ directly from the Alestic.com PPA using the following commands:
168
+
169
+ code=$(lsb_release -cs)
170
+ echo "deb http://ppa.launchpad.net/alestic/ppa/ubuntu $code main"|
171
+ sudo tee /etc/apt/sources.list.d/alestic-ppa.list
172
+ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BE09C571
173
+ sudo apt-get update
174
+ sudo apt-get install -y runurl
175
+
176
+ =head1 BUGS
177
+
178
+ Please report bugs at https://bugs.launchpad.net/runurl
179
+
180
+ =head1 CREDITS
181
+
182
+ Thanks to the following for submitting improvements to the code
183
+
184
+ Scott Moser
185
+
186
+ =head1 AUTHOR
187
+
188
+ Eric Hammond <ehammond@thinksome.com>
189
+
190
+ =head1 LICENSE
191
+
192
+ Copyright 2009 Eric Hammond <ehammond@thinksome.com>
193
+
194
+ Licensed under the Apache License, Version 2.0 (the "License");
195
+ you may not use this file except in compliance with the License.
196
+ You may obtain a copy of the License at
197
+
198
+ http://www.apache.org/licenses/LICENSE-2.0
199
+
200
+ Unless required by applicable law or agreed to in writing, software
201
+ distributed under the License is distributed on an "AS IS" BASIS,
202
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
203
+ See the License for the specific language governing permissions and
204
+ limitations under the License.
205
+
206
+ =cut
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2launcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.31
4
+ version: 1.0.32
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-17 00:00:00.000000000 Z
12
+ date: 2012-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -74,6 +74,7 @@ files:
74
74
  - lib/ec2launcher/instance_paths_config.rb
75
75
  - lib/ec2launcher/security_group_handler.rb
76
76
  - lib/ec2launcher/version.rb
77
+ - startup-scripts/runurl
77
78
  - startup-scripts/setup.rb
78
79
  - startup-scripts/setup_instance.rb
79
80
  homepage: https://github.com/StudyBlue/ec2launcher