capify-ec2 1.4.3 → 1.4.4
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.md +11 -0
- data/lib/capify-ec2.rb +26 -23
- data/lib/capify-ec2/capistrano.rb +12 -10
- data/lib/capify-ec2/version.rb +1 -1
- data/readme.md +8 -0
- metadata +4 -4
data/Changelog.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 1.4.4 (May 15, 2013)
|
2
|
+
|
3
|
+
Features:
|
4
|
+
|
5
|
+
- The EC2 instance tag used to determine instance options can now be customised. Defaults to 'Options' if this setting is ommited.
|
6
|
+
- If the 'Roles' or 'Options' tags are customised, this custom text will be used as the appropriate column headers in the 'ec2:status' command.
|
7
|
+
|
8
|
+
Bugfixes:
|
9
|
+
|
10
|
+
- Fix some issues with customised 'Roles' tags not being respected in all situations.
|
11
|
+
|
1
12
|
## 1.4.3 (Apr 19, 2013)
|
2
13
|
|
3
14
|
Summary of the changes merged from the 'rolling_deploy' branch, from v1.4.0.pre1 to v1.4.3.pre7.
|
data/lib/capify-ec2.rb
CHANGED
@@ -5,7 +5,7 @@ require File.expand_path(File.dirname(__FILE__) + '/capify-ec2/server')
|
|
5
5
|
|
6
6
|
class CapifyEc2
|
7
7
|
|
8
|
-
attr_accessor :load_balancer, :instances
|
8
|
+
attr_accessor :load_balancer, :instances, :ec2_config
|
9
9
|
|
10
10
|
unless const_defined? :SLEEP_COUNT
|
11
11
|
SLEEP_COUNT = 5
|
@@ -25,6 +25,9 @@ class CapifyEc2
|
|
25
25
|
@ec2_config[:project_tags] ||= []
|
26
26
|
# User can change the Roles tag string
|
27
27
|
@ec2_config[:aws_roles_tag] ||= "Roles"
|
28
|
+
# User can change the Options tag string.
|
29
|
+
@ec2_config[:aws_options_tag] ||= "Options"
|
30
|
+
|
28
31
|
@ec2_config[:project_tags] << @ec2_config[:project_tag] if @ec2_config[:project_tag]
|
29
32
|
|
30
33
|
regions = determine_regions()
|
@@ -51,36 +54,36 @@ class CapifyEc2
|
|
51
54
|
end
|
52
55
|
|
53
56
|
# Set minimum widths for the variable length instance attributes.
|
54
|
-
column_widths = { :name_min => 4, :type_min => 4, :dns_min => 5, :roles_min =>
|
57
|
+
column_widths = { :name_min => 4, :type_min => 4, :dns_min => 5, :roles_min => @ec2_config[:aws_roles_tag].length, :options_min => @ec2_config[:aws_options_tag].length }
|
55
58
|
|
56
59
|
# Find the longest attribute across all instances, to format the columns properly.
|
57
|
-
column_widths[:name] = desired_instances.map{|i| i.name.to_s.ljust( column_widths[:name_min] )
|
58
|
-
column_widths[:type] = desired_instances.map{|i| i.flavor_id
|
59
|
-
column_widths[:dns] = desired_instances.map{|i| i.contact_point.to_s.ljust( column_widths[:dns_min] )
|
60
|
-
column_widths[:roles] = desired_instances.map{|i| i.tags[@ec2_config[:aws_roles_tag]].to_s.ljust( column_widths[:roles_min] )
|
61
|
-
column_widths[:options] = desired_instances.map{|i| i.tags[
|
60
|
+
column_widths[:name] = desired_instances.map{|i| i.name.to_s.ljust( column_widths[:name_min] ) || ' ' * column_widths[:name_min] }.max_by(&:length).length
|
61
|
+
column_widths[:type] = desired_instances.map{|i| i.flavor_id || ' ' * column_widths[:type_min] }.max_by(&:length).length
|
62
|
+
column_widths[:dns] = desired_instances.map{|i| i.contact_point.to_s.ljust( column_widths[:dns_min] ) || ' ' * column_widths[:dns_min] }.max_by(&:length).length
|
63
|
+
column_widths[:roles] = desired_instances.map{|i| i.tags[@ec2_config[:aws_roles_tag]].to_s.ljust( column_widths[:roles_min] ) || ' ' * column_widths[:roles_min] }.max_by(&:length).length
|
64
|
+
column_widths[:options] = desired_instances.map{|i| i.tags[@ec2_config[:aws_options_tag]].to_s.ljust( column_widths[:options_min] ) || ' ' * column_widths[:options_min] }.max_by(&:length).length
|
62
65
|
|
63
66
|
# Title row.
|
64
67
|
puts sprintf "%-3s %s %s %s %s %s %s %s",
|
65
|
-
'Num'
|
66
|
-
'Name'
|
67
|
-
'ID'
|
68
|
-
'Type'
|
69
|
-
'DNS'
|
70
|
-
'Zone'
|
71
|
-
|
72
|
-
|
68
|
+
'Num' .bold,
|
69
|
+
'Name' .ljust( column_widths[:name] ).bold,
|
70
|
+
'ID' .ljust( 10 ).bold,
|
71
|
+
'Type' .ljust( column_widths[:type] ).bold,
|
72
|
+
'DNS' .ljust( column_widths[:dns] ).bold,
|
73
|
+
'Zone' .ljust( 10 ).bold,
|
74
|
+
@ec2_config[:aws_roles_tag] .ljust( column_widths[:roles] ).bold,
|
75
|
+
@ec2_config[:aws_options_tag].ljust( column_widths[:options] ).bold
|
73
76
|
|
74
77
|
desired_instances.each_with_index do |instance, i|
|
75
78
|
puts sprintf "%02d: %-10s %s %s %s %-10s %s %s",
|
76
79
|
i,
|
77
|
-
(instance.name || '')
|
78
|
-
instance.id
|
79
|
-
instance.flavor_id
|
80
|
-
instance.contact_point
|
81
|
-
instance.availability_zone
|
82
|
-
(instance.tags[@ec2_config[:aws_roles_tag]] || '').ljust( column_widths[:roles] ).yellow,
|
83
|
-
(instance.tags[
|
80
|
+
(instance.name || '') .ljust( column_widths[:name] ).green,
|
81
|
+
instance.id .ljust( 2 ).red,
|
82
|
+
instance.flavor_id .ljust( column_widths[:type] ).cyan,
|
83
|
+
instance.contact_point .ljust( column_widths[:dns] ).blue.bold,
|
84
|
+
instance.availability_zone .ljust( 10 ).magenta,
|
85
|
+
(instance.tags[@ec2_config[:aws_roles_tag]] || '') .ljust( column_widths[:roles] ).yellow,
|
86
|
+
(instance.tags[@ec2_config[:aws_options_tag]] || '').ljust( column_widths[:options] ).yellow
|
84
87
|
end
|
85
88
|
end
|
86
89
|
|
@@ -102,7 +105,7 @@ class CapifyEc2
|
|
102
105
|
|
103
106
|
def get_instances_by_region(roles, region)
|
104
107
|
return unless region
|
105
|
-
desired_instances.select {|instance| instance.availability_zone.match(region) && instance.tags[
|
108
|
+
desired_instances.select {|instance| instance.availability_zone.match(region) && instance.tags[@ec2_config[:aws_roles_tag]].split(%r{,\s*}).include?(roles.to_s) rescue false}
|
106
109
|
end
|
107
110
|
|
108
111
|
def get_instance_by_name(name)
|
@@ -70,13 +70,15 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
70
70
|
puts "[Capify-EC2] Performing rolling deployment..."
|
71
71
|
|
72
72
|
all_servers = {}
|
73
|
-
|
73
|
+
all_options = {}
|
74
74
|
|
75
75
|
roles.each do |role|
|
76
76
|
role[1].servers.each do |s|
|
77
|
-
|
78
|
-
all_servers[
|
79
|
-
|
77
|
+
server_dns = s.host.to_s
|
78
|
+
all_servers[ server_dns ] ||= []
|
79
|
+
all_servers[ server_dns ] << role[0]
|
80
|
+
all_options[ role[0] ] ||= {}
|
81
|
+
all_options[ role[0] ][ server_dns ] = (s.options || {})
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
@@ -95,8 +97,8 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
95
97
|
is_load_balanced = false
|
96
98
|
|
97
99
|
server_roles.each do |a_role|
|
98
|
-
role a_role, server_dns,
|
99
|
-
is_load_balanced = true if
|
100
|
+
role a_role, server_dns, all_options[a_role][server_dns]
|
101
|
+
is_load_balanced = true if all_options[a_role][server_dns][:load_balanced]
|
100
102
|
end
|
101
103
|
|
102
104
|
puts "[Capify-EC2]"
|
@@ -110,8 +112,8 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
110
112
|
server_roles.each do |a_role|
|
111
113
|
|
112
114
|
# If healthcheck(s) are defined for this role, run them.
|
113
|
-
if
|
114
|
-
healthchecks_for_role = [
|
115
|
+
if all_options[a_role][server_dns][:healthcheck]
|
116
|
+
healthchecks_for_role = [ all_options[a_role][server_dns][:healthcheck] ].flatten
|
115
117
|
|
116
118
|
puts "[Capify-EC2] Starting #{pluralise(healthchecks_for_role.size, 'healthcheck')} for role '#{a_role}'..."
|
117
119
|
|
@@ -204,7 +206,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
204
206
|
if named_instance.respond_to?(:roles)
|
205
207
|
roles = named_instance.roles
|
206
208
|
else
|
207
|
-
roles = [named_instance.tags[
|
209
|
+
roles = [named_instance.tags[ @ec2_config[:aws_roles_tag] ]].flatten
|
208
210
|
end
|
209
211
|
|
210
212
|
roles.each do |role|
|
@@ -275,7 +277,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
275
277
|
cap_options
|
276
278
|
end
|
277
279
|
|
278
|
-
ec2_options = instance.tags[
|
280
|
+
ec2_options = instance.tags[capify_ec2.ec2_config[:aws_options_tag]] || ""
|
279
281
|
ec2_options.split(%r{,\s*}).compact.each { |ec2_option| cap_options[ec2_option.to_sym] = true }
|
280
282
|
|
281
283
|
variables.each do |key, value|
|
data/lib/capify-ec2/version.rb
CHANGED
data/readme.md
CHANGED
@@ -50,6 +50,14 @@ Note: 'aws_access_key_id', 'aws_secret_access_key', and 'region' are required. O
|
|
50
50
|
When ':load_balanced' is set to 'true', Capify-EC2 uses pre and post-deploy hooks to deregister the instance from an associated Elastic Load Balancer, perform the actual deploy, then finally reregister with the ELB and validated the instance health.
|
51
51
|
Note: This options only applies to deployments made to an individual instance, using the command 'cap INSTANCE_NAME_HERE deploy' - it doesn't apply to roles.
|
52
52
|
|
53
|
+
* :aws_roles_tag
|
54
|
+
|
55
|
+
Use this option to change which EC2 instance tag Capify-EC2 uses to determine instance roles. Defaults to 'Roles' if ommited.
|
56
|
+
|
57
|
+
* :aws_options_tag
|
58
|
+
|
59
|
+
Use this option to change which EC2 instance tag Capify-EC2 uses to determine instance options. Defaults to 'Options' if ommited.
|
60
|
+
|
53
61
|
|
54
62
|
|
55
63
|
#### EC2 Tags
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capify-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 4
|
10
|
+
version: 1.4.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Noah Cantor
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2013-
|
21
|
+
date: 2013-05-15 00:00:00 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: fog
|