ec2launcher 1.0.25 → 1.0.26
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/ec2launcher/backoff_runner.rb +7 -1
- data/lib/ec2launcher/dsl/application.rb +13 -75
- data/lib/ec2launcher/dsl/block_device.rb +11 -63
- data/lib/ec2launcher/dsl/email_notification.rb +7 -37
- data/lib/ec2launcher/dsl/environment.rb +21 -144
- data/lib/ec2launcher/dsl/helper.rb +40 -0
- data/lib/ec2launcher/version.rb +1 -1
- data/startup-scripts/setup_instance.rb +5 -5
- metadata +3 -2
data/CHANGELOG.md
CHANGED
@@ -25,7 +25,13 @@ module EC2Launcher
|
|
25
25
|
puts "AWS::EC2::Errors::RequestLimitExceeded ... retrying #{message} in #{sleep_time} seconds"
|
26
26
|
sleep sleep_time
|
27
27
|
run_with_backoff(max_time, sleep_time * 2, message, &block)
|
28
|
-
|
28
|
+
rescue AWS::EC2::Errors::InstanceLimitExceeded
|
29
|
+
puts "AWS::EC2::Errors::InstanceLimitExceeded ... aborting launch."
|
30
|
+
return false
|
31
|
+
rescue StdError => bang
|
32
|
+
print "Error for #{message}: #{bang}"
|
33
|
+
return false
|
34
|
+
end
|
29
35
|
true
|
30
36
|
end
|
31
37
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 2012 Sean Laurent
|
3
3
|
#
|
4
|
+
require 'ec2launcher/dsl/helper'
|
4
5
|
require 'ec2launcher/dsl/block_device'
|
5
6
|
require 'ec2launcher/dsl/email_notification'
|
6
7
|
require 'ec2launcher/security_group_handler'
|
@@ -32,10 +33,22 @@ module EC2Launcher
|
|
32
33
|
# Represents a single application stack.
|
33
34
|
class Application
|
34
35
|
include EC2Launcher::DSL::EmailNotifications
|
36
|
+
include EC2Launcher::DSL::Helper
|
35
37
|
include EC2Launcher::SecurityGroupHandler
|
36
38
|
|
39
|
+
|
37
40
|
attr_reader :name
|
38
41
|
|
42
|
+
dsl_accessor :basename
|
43
|
+
dsl_accessor :inherit
|
44
|
+
dsl_accessor :instance_type
|
45
|
+
dsl_accessor :name_suffix
|
46
|
+
dsl_accessor :subnet
|
47
|
+
|
48
|
+
dsl_array_accessor :gems
|
49
|
+
dsl_array_accessor :packages
|
50
|
+
dsl_array_accessor :roles
|
51
|
+
|
39
52
|
def initialize(name)
|
40
53
|
@name = name
|
41
54
|
@email_notifications = nil
|
@@ -75,19 +88,6 @@ module EC2Launcher
|
|
75
88
|
end
|
76
89
|
end
|
77
90
|
|
78
|
-
# Defines a shorter name when building a host name for new instances. Optional.
|
79
|
-
# By default, new instances are named using the full application name. If you
|
80
|
-
# specify basename, it will be used instead. Typically, this is used if you
|
81
|
-
# want a shorter version of the full application name.
|
82
|
-
def basename(*name)
|
83
|
-
if name.empty?
|
84
|
-
@basename
|
85
|
-
else
|
86
|
-
@basename = name[0]
|
87
|
-
self
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
91
|
def block_devices(*block_device_data)
|
92
92
|
if block_device_data.empty?
|
93
93
|
@block_devices
|
@@ -177,27 +177,6 @@ module EC2Launcher
|
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
180
|
-
# Indicates that this application should inherit all of its settings from another named application.
|
181
|
-
# Optional.
|
182
|
-
def inherit(*inherit_type)
|
183
|
-
if inherit_type.empty?
|
184
|
-
@inherit_type
|
185
|
-
else
|
186
|
-
@inherit_type = inherit_type[0]
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
# The Amazon EC2 instance type that should be used for new instances.
|
191
|
-
# Must be one of EC2Launcher::INSTANCE_TYPES.
|
192
|
-
def instance_type(*type_name)
|
193
|
-
if type_name.empty?
|
194
|
-
@instance_type
|
195
|
-
else
|
196
|
-
@instance_type = type_name[0]
|
197
|
-
self
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
180
|
# Takes values from the other server type and merges them into this one
|
202
181
|
def merge(other_server)
|
203
182
|
@name = other_server.name
|
@@ -234,38 +213,6 @@ module EC2Launcher
|
|
234
213
|
end
|
235
214
|
end
|
236
215
|
|
237
|
-
def name_suffix(*suffix)
|
238
|
-
if suffix.empty?
|
239
|
-
@name_suffix
|
240
|
-
else
|
241
|
-
@name_suffix = suffix[0]
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
def packages(*packages)
|
246
|
-
if packages.empty?
|
247
|
-
@packages
|
248
|
-
else
|
249
|
-
@packages = packages[0]
|
250
|
-
self
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
def roles(*roles)
|
255
|
-
if roles.empty?
|
256
|
-
@roles
|
257
|
-
else
|
258
|
-
@roles = [] if @roles.nil?
|
259
|
-
if roles[0].kind_of? Array
|
260
|
-
@roles += roles[0]
|
261
|
-
else
|
262
|
-
@roles = []
|
263
|
-
@roles << roles[0]
|
264
|
-
end
|
265
|
-
self
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
216
|
def roles_for_environment(environment)
|
270
217
|
roles = []
|
271
218
|
roles += @roles unless @roles.nil?
|
@@ -289,15 +236,6 @@ module EC2Launcher
|
|
289
236
|
groups
|
290
237
|
end
|
291
238
|
|
292
|
-
def subnet(*subnet)
|
293
|
-
if subnet.empty?
|
294
|
-
@subnet
|
295
|
-
else
|
296
|
-
@subnet = subnet[0]
|
297
|
-
self
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
239
|
def load(dsl)
|
302
240
|
self.instance_eval(dsl)
|
303
241
|
self
|
@@ -1,13 +1,24 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 2012 Sean Laurent
|
3
3
|
#
|
4
|
+
require 'ec2launcher/dsl/helper'
|
4
5
|
|
5
6
|
module EC2Launcher
|
6
7
|
module DSL
|
7
8
|
class BlockDevice
|
9
|
+
include EC2Launcher::DSL::Helper
|
10
|
+
|
8
11
|
attr_reader :mount_point
|
9
12
|
attr_reader :name
|
10
13
|
|
14
|
+
dsl_accessor :count
|
15
|
+
dsl_accessor :group
|
16
|
+
dsl_accessor :mount
|
17
|
+
dsl_accessor :name
|
18
|
+
dsl_accessor :owner
|
19
|
+
dsl_accessor :raid_level
|
20
|
+
dsl_accessor :size
|
21
|
+
|
11
22
|
def initialize()
|
12
23
|
@count = 1
|
13
24
|
@group = "root"
|
@@ -18,69 +29,6 @@ module EC2Launcher
|
|
18
29
|
@raid_level.nil?
|
19
30
|
end
|
20
31
|
|
21
|
-
def count(*block_count)
|
22
|
-
if block_count.empty?
|
23
|
-
@count
|
24
|
-
else
|
25
|
-
@count = block_count[0]
|
26
|
-
self
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def group(*group)
|
31
|
-
if group.empty?
|
32
|
-
@group
|
33
|
-
else
|
34
|
-
@group = group[0]
|
35
|
-
self
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def mount(*mount)
|
40
|
-
if mount.empty?
|
41
|
-
@mount
|
42
|
-
else
|
43
|
-
@mount_point = mount[0]
|
44
|
-
self
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def name(*name)
|
49
|
-
if name.empty?
|
50
|
-
@name
|
51
|
-
else
|
52
|
-
@name = name[0]
|
53
|
-
self
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def owner(*owner)
|
58
|
-
if owner.empty?
|
59
|
-
@owner
|
60
|
-
else
|
61
|
-
@owner = owner[0]
|
62
|
-
self
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def raid_level(*raid_level)
|
67
|
-
if raid_level.empty?
|
68
|
-
@raid_level
|
69
|
-
else
|
70
|
-
@raid_level = raid_level[0]
|
71
|
-
self
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def size(*volume_size)
|
76
|
-
if volume_size.empty?
|
77
|
-
@size
|
78
|
-
else
|
79
|
-
@size = volume_size[0].to_i
|
80
|
-
self
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
32
|
def to_json(*a)
|
85
33
|
{
|
86
34
|
"name" => @name,
|
@@ -1,10 +1,12 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 2012 Sean Laurent
|
3
3
|
#
|
4
|
+
require 'ec2launcher/dsl/helper'
|
4
5
|
|
5
6
|
module EC2Launcher
|
6
7
|
module DSL
|
7
8
|
module EmailNotifications
|
9
|
+
|
8
10
|
attr_reader :email_notifications
|
9
11
|
|
10
12
|
def email_notification(&block)
|
@@ -15,44 +17,12 @@ module EC2Launcher
|
|
15
17
|
end
|
16
18
|
|
17
19
|
class EmailNotification
|
18
|
-
|
19
|
-
end
|
20
|
+
include EC2Launcher::DSL::Helper
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@from = from[0]
|
26
|
-
self
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def to(*to)
|
31
|
-
if to.empty?
|
32
|
-
@to
|
33
|
-
else
|
34
|
-
@to = to[0]
|
35
|
-
self
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def ses_access_key(*ses_access_key)
|
40
|
-
if ses_access_key.empty?
|
41
|
-
@ses_access_key
|
42
|
-
else
|
43
|
-
@ses_access_key = ses_access_key[0]
|
44
|
-
self
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def ses_secret_key(*ses_secret_key)
|
49
|
-
if ses_secret_key.empty?
|
50
|
-
@ses_secret_key
|
51
|
-
else
|
52
|
-
@ses_secret_key = ses_secret_key[0]
|
53
|
-
self
|
54
|
-
end
|
55
|
-
end
|
22
|
+
dsl_accessor :from
|
23
|
+
dsl_accessor :to
|
24
|
+
dsl_accessor :ses_access_key
|
25
|
+
dsl_accessor :ses_secret_key
|
56
26
|
|
57
27
|
def to_json(*a)
|
58
28
|
{
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 2012 Sean Laurent
|
3
3
|
#
|
4
|
+
require 'ec2launcher/dsl/helper'
|
4
5
|
require 'ec2launcher/dsl/email_notification'
|
5
6
|
require 'ec2launcher/security_group_handler'
|
6
7
|
|
@@ -8,12 +9,32 @@ module EC2Launcher
|
|
8
9
|
module DSL
|
9
10
|
class Environment
|
10
11
|
include EC2Launcher::DSL::EmailNotifications
|
12
|
+
include EC2Launcher::DSL::Helper
|
11
13
|
include EC2Launcher::SecurityGroupHandler
|
12
14
|
|
13
15
|
attr_reader :name
|
14
16
|
attr_reader :precommands
|
15
17
|
attr_reader :postcommands
|
16
18
|
|
19
|
+
dsl_accessor :aws_keyfile
|
20
|
+
dsl_accessor :chef_path
|
21
|
+
dsl_accessor :chef_server_url
|
22
|
+
dsl_accessor :chef_validation_pem_url
|
23
|
+
dsl_accessor :domain_name
|
24
|
+
dsl_accessor :gem_path
|
25
|
+
dsl_accessor :inherit
|
26
|
+
dsl_accessor :key_name
|
27
|
+
dsl_accessor :knife_path
|
28
|
+
dsl_accessor :ruby_path
|
29
|
+
dsl_accessor :short_name
|
30
|
+
dsl_accessor :subnet
|
31
|
+
|
32
|
+
dsl_array_accessor :gems
|
33
|
+
dsl_array_accessor :packages
|
34
|
+
dsl_array_accessor :precommand
|
35
|
+
dsl_array_accessor :postcommand
|
36
|
+
dsl_array_accessor :roles
|
37
|
+
|
17
38
|
def initialize()
|
18
39
|
@aliases = []
|
19
40
|
@email_notifications = nil
|
@@ -31,15 +52,6 @@ module EC2Launcher
|
|
31
52
|
self
|
32
53
|
end
|
33
54
|
|
34
|
-
def aws_keyfile(*aws_keyfile)
|
35
|
-
if aws_keyfile.empty?
|
36
|
-
@aws_keyfile
|
37
|
-
else
|
38
|
-
@aws_keyfile = aws_keyfile[0]
|
39
|
-
self
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
55
|
def aliases(*aliases)
|
44
56
|
if aliases.empty?
|
45
57
|
@aliases
|
@@ -74,141 +86,6 @@ module EC2Launcher
|
|
74
86
|
end
|
75
87
|
end
|
76
88
|
|
77
|
-
def chef_server_url(*server_url)
|
78
|
-
if server_url.empty?
|
79
|
-
@chef_server_url
|
80
|
-
else
|
81
|
-
@chef_server_url = server_url[0]
|
82
|
-
self
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def chef_validation_pem_url(*chef_validation_pem_url)
|
87
|
-
if chef_validation_pem_url.empty?
|
88
|
-
@chef_validation_pem_url
|
89
|
-
else
|
90
|
-
@chef_validation_pem_url = chef_validation_pem_url[0]
|
91
|
-
self
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def domain_name(*domain_name)
|
96
|
-
if domain_name.empty?
|
97
|
-
@domain_name
|
98
|
-
else
|
99
|
-
@domain_name = domain_name[0]
|
100
|
-
self
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def gems(*gems)
|
105
|
-
if gems.empty?
|
106
|
-
@gems
|
107
|
-
else
|
108
|
-
@gems = gems[0]
|
109
|
-
self
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def gem_path(*gem_path)
|
114
|
-
if gem_path.empty?
|
115
|
-
@gem_path
|
116
|
-
else
|
117
|
-
@gem_path = gem_path[0]
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def ruby_path(*ruby_path)
|
122
|
-
if ruby_path.empty?
|
123
|
-
@ruby_path
|
124
|
-
else
|
125
|
-
@ruby_path = ruby_path[0]
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def chef_path(*chef_path)
|
130
|
-
if chef_path.empty?
|
131
|
-
@chef_path
|
132
|
-
else
|
133
|
-
@chef_path = chef_path[0]
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def knife_path(*knife_path)
|
138
|
-
if knife_path.empty?
|
139
|
-
@knife_path
|
140
|
-
else
|
141
|
-
@knife_path = knife_path[0]
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def inherit(*inherit_type)
|
146
|
-
if inherit_type.empty?
|
147
|
-
@inherit_type
|
148
|
-
else
|
149
|
-
@inherit_type = inherit_type[0]
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def key_name(*key)
|
154
|
-
if key.empty?
|
155
|
-
@key_name
|
156
|
-
else
|
157
|
-
@key_name = key[0]
|
158
|
-
self
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def packages(*packages)
|
163
|
-
if packages.empty?
|
164
|
-
@packages
|
165
|
-
else
|
166
|
-
@packages = packages[0]
|
167
|
-
self
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def precommand(*command)
|
172
|
-
@precommands << command[0]
|
173
|
-
end
|
174
|
-
|
175
|
-
def postcommand(*command)
|
176
|
-
@postcommands << command[0]
|
177
|
-
end
|
178
|
-
|
179
|
-
def roles(*roles)
|
180
|
-
if roles.empty?
|
181
|
-
@roles
|
182
|
-
else
|
183
|
-
@roles = [] if @roles.nil?
|
184
|
-
if roles[0].kind_of? Array
|
185
|
-
@roles += roles[0]
|
186
|
-
else
|
187
|
-
@roles = []
|
188
|
-
@roles << roles[0]
|
189
|
-
end
|
190
|
-
self
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def short_name(*short_name)
|
195
|
-
if short_name.empty?
|
196
|
-
@short_name
|
197
|
-
else
|
198
|
-
@short_name = short_name[0]
|
199
|
-
self
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
def subnet(*subnet)
|
204
|
-
if subnet.empty?
|
205
|
-
@subnet
|
206
|
-
else
|
207
|
-
@subnet = subnet[0]
|
208
|
-
self
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
89
|
# Takes values from the other environment and merges them into this one
|
213
90
|
def merge(other_env)
|
214
91
|
@name =other_env.name
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module EC2Launcher
|
2
|
+
module DSL
|
3
|
+
module Helper
|
4
|
+
def dsl_accessor(*symbols)
|
5
|
+
symbols.each { |sym|
|
6
|
+
class_eval %{
|
7
|
+
def #{sym}(*val)
|
8
|
+
if val.empty
|
9
|
+
@#{sym}
|
10
|
+
else
|
11
|
+
@#{sym} = val.size == 1 ? val[0] : val
|
12
|
+
self
|
13
|
+
end
|
14
|
+
end
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def dsl_array_accessor(*symbols)
|
20
|
+
symbols.each { |sym|
|
21
|
+
class_eval %{
|
22
|
+
def #{sym}(*val)
|
23
|
+
if val.empty
|
24
|
+
@#{sym}
|
25
|
+
else
|
26
|
+
@#{sym} = [] if @#{sym}.nil?
|
27
|
+
if val[0].kind_of? Array
|
28
|
+
@#{sym} += val[0]
|
29
|
+
else
|
30
|
+
@#{sym} << val[0]
|
31
|
+
end
|
32
|
+
self
|
33
|
+
end
|
34
|
+
end
|
35
|
+
}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/ec2launcher/version.rb
CHANGED
@@ -379,11 +379,11 @@ if instance_data["email_notifications"]
|
|
379
379
|
})
|
380
380
|
ses = AWS::SimpleEmailService.new
|
381
381
|
ses.send_email(
|
382
|
-
:from => instance_data["
|
383
|
-
:to => instance_data["
|
384
|
-
:subject => "Server setup complete: #{hostname}",
|
385
|
-
:body_text => "Server setup is complete for Host: #{hostname}, Environment: #{options.environ}, Application: #{options.application}",
|
386
|
-
:body_html => "<div>Server setup is complete for:</div><div><strong>Host:</strong> #{hostname}</div><div><strong>Environment:</strong> #{options.environ}</div><div><strong>Application:</strong> #{options.application}</div>"
|
382
|
+
:from => instance_data["email_notifications"]["from"],
|
383
|
+
:to => instance_data["email_notifications"]["to"],
|
384
|
+
:subject => "Server setup complete: #{options.hostname}",
|
385
|
+
:body_text => "Server setup is complete for Host: #{options.hostname}, Environment: #{options.environ}, Application: #{options.application}",
|
386
|
+
:body_html => "<div>Server setup is complete for:</div><div><strong>Host:</strong> #{options.hostname}</div><div><strong>Environment:</strong> #{options.environ}</div><div><strong>Application:</strong> #{options.application}</div>"
|
387
387
|
)
|
388
388
|
else
|
389
389
|
puts "Skipping email notification."
|
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.
|
4
|
+
version: 1.0.26
|
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-
|
12
|
+
date: 2012-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/ec2launcher/dsl/config.rb
|
69
69
|
- lib/ec2launcher/dsl/email_notification.rb
|
70
70
|
- lib/ec2launcher/dsl/environment.rb
|
71
|
+
- lib/ec2launcher/dsl/helper.rb
|
71
72
|
- lib/ec2launcher/hostname_generator.rb
|
72
73
|
- lib/ec2launcher/init_options.rb
|
73
74
|
- lib/ec2launcher/instance_paths_config.rb
|