rubber 1.6.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -0
- data/VERSION +1 -1
- data/lib/rubber/cloud/aws.rb +15 -0
- data/lib/rubber/instance.rb +1 -1
- data/lib/rubber/recipes/rubber/bundles.rb +2 -0
- data/lib/rubber/recipes/rubber/instances.rb +90 -4
- metadata +5 -5
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.7.0
|
data/lib/rubber/cloud/aws.rb
CHANGED
@@ -44,6 +44,7 @@ module Rubber
|
|
44
44
|
instance[:state] = item.instanceState.name
|
45
45
|
instance[:zone] = item.placement.availabilityZone
|
46
46
|
instance[:platform] = item.platform || 'linux'
|
47
|
+
instance[:root_device_type] = item.rootDeviceType
|
47
48
|
instances << instance
|
48
49
|
end
|
49
50
|
end if response.reservationSet
|
@@ -55,6 +56,19 @@ module Rubber
|
|
55
56
|
response = @ec2.terminate_instances(:instance_id => instance_id)
|
56
57
|
end
|
57
58
|
|
59
|
+
def reboot_instance(instance_id)
|
60
|
+
response = @ec2.reboot_instances(:instance_id => instance_id)
|
61
|
+
end
|
62
|
+
|
63
|
+
def stop_instance(instance_id)
|
64
|
+
# Don't force the stop process. I.e., allow the instance to flush its file system operations.
|
65
|
+
response = @ec2.stop_instances(:instance_id => instance_id, :force => false)
|
66
|
+
end
|
67
|
+
|
68
|
+
def start_instance(instance_id)
|
69
|
+
response = @ec2.start_instances(:instance_id => instance_id)
|
70
|
+
end
|
71
|
+
|
58
72
|
def describe_availability_zones
|
59
73
|
zones = []
|
60
74
|
response = @ec2.describe_availability_zones()
|
@@ -259,6 +273,7 @@ module Rubber
|
|
259
273
|
image = {}
|
260
274
|
image[:id] = item.imageId
|
261
275
|
image[:location] = item.imageLocation
|
276
|
+
image[:root_device_type] = item.rootDeviceType
|
262
277
|
images << image
|
263
278
|
end if response.imagesSet
|
264
279
|
return images
|
data/lib/rubber/instance.rb
CHANGED
@@ -80,7 +80,7 @@ module Rubber
|
|
80
80
|
attr_accessor :roles, :zone
|
81
81
|
attr_accessor :external_host, :external_ip
|
82
82
|
attr_accessor :internal_host, :internal_ip
|
83
|
-
attr_accessor :static_ip, :volumes, :partitions
|
83
|
+
attr_accessor :static_ip, :volumes, :partitions, :root_device_type
|
84
84
|
attr_accessor :spot_instance_request_id
|
85
85
|
attr_accessor :platform
|
86
86
|
|
@@ -20,8 +20,10 @@ namespace :rubber do
|
|
20
20
|
required_task :describe_bundles do
|
21
21
|
images = cloud.describe_images()
|
22
22
|
images.each do |image|
|
23
|
+
logger.info "======================"
|
23
24
|
logger.info "ID: #{image[:id]}"
|
24
25
|
logger.info "Location: #{image[:location]}"
|
26
|
+
logger.info "Root device type: #{image[:root_device_type]}"
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -42,7 +42,7 @@ namespace :rubber do
|
|
42
42
|
Refresh the host data for a EC2 instance with the given ALIAS.
|
43
43
|
This is useful to run when rubber:create fails after instance creation
|
44
44
|
DESC
|
45
|
-
|
45
|
+
required_task :refresh do
|
46
46
|
instance_alias = get_env('ALIAS', "Instance alias (e.g. web01)", true)
|
47
47
|
ENV.delete('ROLES') # so we don't get an error if people leave ROLES in env from :create CLI
|
48
48
|
refresh_instance(instance_alias)
|
@@ -51,7 +51,7 @@ namespace :rubber do
|
|
51
51
|
desc <<-DESC
|
52
52
|
Destroy the EC2 instance for the given ALIAS
|
53
53
|
DESC
|
54
|
-
|
54
|
+
required_task :destroy do
|
55
55
|
instance_alias = get_env('ALIAS', "Instance alias (e.g. web01)", true)
|
56
56
|
ENV.delete('ROLES') # so we don't get an error if people leave ROLES in env from :create CLI
|
57
57
|
destroy_instance(instance_alias)
|
@@ -60,12 +60,39 @@ namespace :rubber do
|
|
60
60
|
desc <<-DESC
|
61
61
|
Destroy ALL the EC2 instances for the current env
|
62
62
|
DESC
|
63
|
-
|
63
|
+
required_task :destroy_all do
|
64
64
|
rubber_instances.each do |ic|
|
65
65
|
destroy_instance(ic.name)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
desc <<-DESC
|
70
|
+
Reboot the EC2 instance for the give ALIAS
|
71
|
+
DESC
|
72
|
+
required_task :reboot do
|
73
|
+
instance_alias = get_env('ALIAS', "Instance alias (e.g. web01)", true)
|
74
|
+
ENV.delete('ROLES') # so we don't get an error if people leave ROLES in env from :create CLI
|
75
|
+
reboot_instance(instance_alias)
|
76
|
+
end
|
77
|
+
|
78
|
+
desc <<-DESC
|
79
|
+
Stop the EC2 instance for the give ALIAS
|
80
|
+
DESC
|
81
|
+
required_task :stop do
|
82
|
+
instance_alias = get_env('ALIAS', "Instance alias (e.g. web01)", true)
|
83
|
+
ENV.delete('ROLES') # so we don't get an error if people leave ROLES in env from :create CLI
|
84
|
+
stop_instance(instance_alias)
|
85
|
+
end
|
86
|
+
|
87
|
+
desc <<-DESC
|
88
|
+
Start the EC2 instance for the give ALIAS
|
89
|
+
DESC
|
90
|
+
required_task :start do
|
91
|
+
instance_alias = get_env('ALIAS', "Instance alias (e.g. web01)", true)
|
92
|
+
ENV.delete('ROLES') # so we don't get an error if people leave ROLES in env from :create CLI
|
93
|
+
start_instance(instance_alias)
|
94
|
+
end
|
95
|
+
|
69
96
|
desc <<-DESC
|
70
97
|
Adds the given ROLES to the instance named ALIAS
|
71
98
|
DESC
|
@@ -218,7 +245,6 @@ namespace :rubber do
|
|
218
245
|
sleep 2
|
219
246
|
|
220
247
|
break if refresh_instance(instance_alias)
|
221
|
-
|
222
248
|
end
|
223
249
|
end
|
224
250
|
|
@@ -242,6 +268,7 @@ namespace :rubber do
|
|
242
268
|
instance_item.internal_ip = instance[:internal_ip]
|
243
269
|
instance_item.zone = instance[:zone]
|
244
270
|
instance_item.platform = instance[:platform]
|
271
|
+
instance_item.root_device_type = instance[:root_device_type]
|
245
272
|
rubber_instances.save()
|
246
273
|
|
247
274
|
unless instance_item.windows?
|
@@ -323,6 +350,65 @@ namespace :rubber do
|
|
323
350
|
cleanup_known_hosts(instance_item) unless env.disable_known_hosts_cleanup
|
324
351
|
end
|
325
352
|
|
353
|
+
# Reboots the given ec2 instance
|
354
|
+
def reboot_instance(instance_alias)
|
355
|
+
instance_item = rubber_instances[instance_alias]
|
356
|
+
fatal "Instance does not exist: #{instance_alias}" if ! instance_item
|
357
|
+
|
358
|
+
env = rubber_cfg.environment.bind(instance_item.role_names, instance_item.name)
|
359
|
+
|
360
|
+
value = Capistrano::CLI.ui.ask("About to REBOOT #{instance_alias} (#{instance_item.instance_id}) in mode #{RUBBER_ENV}. Are you SURE [yes/NO]?: ")
|
361
|
+
fatal("Exiting", 0) if value != "yes"
|
362
|
+
|
363
|
+
logger.info "Rebooting instance alias=#{instance_alias}, instance_id=#{instance_item.instance_id}"
|
364
|
+
|
365
|
+
cloud.reboot_instance(instance_item.instance_id)
|
366
|
+
end
|
367
|
+
|
368
|
+
# Stops the given ec2 instance. Note that this operation only works for instances that use an EBS volume for the root
|
369
|
+
# device and that are not spot instances.
|
370
|
+
def stop_instance(instance_alias)
|
371
|
+
instance_item = rubber_instances[instance_alias]
|
372
|
+
fatal "Instance does not exist: #{instance_alias}" if ! instance_item
|
373
|
+
fatal "Cannot stop spot instances!" if ! instance_item.spot_instance_request_id.nil?
|
374
|
+
fatal "Cannot stop instances with instance-store root device!" if (instance_item.root_device_type != 'ebs')
|
375
|
+
|
376
|
+
env = rubber_cfg.environment.bind(instance_item.role_names, instance_item.name)
|
377
|
+
|
378
|
+
value = Capistrano::CLI.ui.ask("About to STOP #{instance_alias} (#{instance_item.instance_id}) in mode #{RUBBER_ENV}. Are you SURE [yes/NO]?: ")
|
379
|
+
fatal("Exiting", 0) if value != "yes"
|
380
|
+
|
381
|
+
logger.info "Stopping instance alias=#{instance_alias}, instance_id=#{instance_item.instance_id}"
|
382
|
+
|
383
|
+
cloud.stop_instance(instance_item.instance_id)
|
384
|
+
end
|
385
|
+
|
386
|
+
# Starts the given ec2 instance. Note that this operation only works for instances that use an EBS volume for the root
|
387
|
+
# device, that are not spot instances, and that are already stopped.
|
388
|
+
def start_instance(instance_alias)
|
389
|
+
instance_item = rubber_instances[instance_alias]
|
390
|
+
fatal "Instance does not exist: #{instance_alias}" if ! instance_item
|
391
|
+
fatal "Cannot start spot instances!" if ! instance_item.spot_instance_request_id.nil?
|
392
|
+
fatal "Cannot start instances with instance-store root device!" if (instance_item.root_device_type != 'ebs')
|
393
|
+
|
394
|
+
env = rubber_cfg.environment.bind(instance_item.role_names, instance_item.name)
|
395
|
+
|
396
|
+
value = Capistrano::CLI.ui.ask("About to START #{instance_alias} (#{instance_item.instance_id}) in mode #{RUBBER_ENV}. Are you SURE [yes/NO]?: ")
|
397
|
+
fatal("Exiting", 0) if value != "yes"
|
398
|
+
|
399
|
+
logger.info "Starting instance alias=#{instance_alias}, instance_id=#{instance_item.instance_id}"
|
400
|
+
|
401
|
+
cloud.start_instance(instance_item.instance_id)
|
402
|
+
|
403
|
+
# Re-starting an instance will almost certainly give it a new set of IPs and DNS entries, so refresh the values.
|
404
|
+
print "Waiting for instance to start"
|
405
|
+
while true do
|
406
|
+
print "."
|
407
|
+
sleep 2
|
408
|
+
|
409
|
+
break if refresh_instance(instance_alias)
|
410
|
+
end
|
411
|
+
end
|
326
412
|
|
327
413
|
# delete from ~/.ssh/known_hosts all lines that begin with ec2- or instance_alias
|
328
414
|
def cleanup_known_hosts(instance_item)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 1.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Conway
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-01 00:00:00 -04:00
|
19
19
|
default_executable: vulcanize
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|