capify-ec2 1.1.12.pre → 1.1.12.pre.1
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/lib/capify-ec2.rb +14 -4
- data/lib/capify-ec2/capistrano.rb +6 -4
- data/lib/capify-ec2/version.rb +1 -1
- metadata +3 -2
data/lib/capify-ec2.rb
CHANGED
@@ -53,21 +53,31 @@ class CapifyEc2
|
|
53
53
|
elb.describe_instance_health(load_balancer.id, instance.id).body['DescribeInstanceHealthResult']['InstanceStates'][0]['State']
|
54
54
|
end
|
55
55
|
|
56
|
-
def self.get_instances_by_role(role, server_type
|
57
|
-
|
56
|
+
def self.get_instances_by_role(role, server_type)
|
57
|
+
filter_instances_by_role(running_instances, role, server_type)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.get_instances_by_region(role, region)
|
61
|
+
return unless region
|
62
|
+
region_instances = running_instances(region)
|
63
|
+
filter_instances_by_role(region_instances,role)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.filter_instances_by_role(instances, role, server_type = nil)
|
67
|
+
selected_instances = instances.select do |instance|
|
58
68
|
server_roles = [instance.case_insensitive_tag("Role")] || []
|
59
69
|
if (roles_tag = instance.case_insensitive_tag("Roles"))
|
60
70
|
server_roles += roles_tag.split(/\s*,\s*/)
|
61
71
|
end
|
62
72
|
server_type.nil? ? server_roles.member?(role.to_s) : (server_roles.member?(role.to_s) && server_type == role.to_s)
|
63
73
|
end
|
64
|
-
end
|
74
|
+
end
|
65
75
|
|
66
76
|
def self.get_instance_by_name(name)
|
67
77
|
selected_instances = running_instances.select do |instance|
|
68
78
|
value = instance.case_insensitive_tag("Name")
|
69
79
|
value == name.to_s
|
70
|
-
end
|
80
|
+
end.first
|
71
81
|
end
|
72
82
|
|
73
83
|
def self.server_names
|
@@ -6,7 +6,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
6
6
|
role = role_name_or_hash.is_a?(Hash) ? role_name_or_hash : {:name => role_name_or_hash,:options => {}}
|
7
7
|
server_type = variables[:logger].instance_variable_get("@options")[:actions].first unless variables[:logger].instance_variable_get("@options")[:actions][1].nil?
|
8
8
|
instances = CapifyEc2.get_instances_by_role(role[:name], server_type)
|
9
|
-
|
10
9
|
if role[:options].delete(:default)
|
11
10
|
instances.each do |instance|
|
12
11
|
define_role(role, instance)
|
@@ -15,15 +14,18 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
15
14
|
|
16
15
|
regions = CapifyEc2.ec2_config[:aws_params][:regions] || [CapifyEc2.ec2_config[:aws_params][:region]]
|
17
16
|
regions.each do |region|
|
18
|
-
define_regions(region, role
|
17
|
+
define_regions(region, role)
|
19
18
|
end unless regions.nil?
|
20
19
|
|
21
20
|
define_instance_roles(role, instances)
|
22
21
|
define_role_roles(role, instances)
|
22
|
+
|
23
|
+
named_instance = CapifyEc2.get_instance_by_name(server_type)
|
24
|
+
define_instance_roles(role, [named_instance]) unless named_instance.nil?
|
23
25
|
end
|
24
26
|
|
25
|
-
def define_regions(region, role
|
26
|
-
instances = CapifyEc2.
|
27
|
+
def define_regions(region, role)
|
28
|
+
instances = CapifyEc2.get_instances_by_region(role[:name], region)
|
27
29
|
task region.to_sym do
|
28
30
|
instances.each do |instance|
|
29
31
|
define_role(role, instance)
|
data/lib/capify-ec2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capify-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1923832059
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
9
|
- 12
|
10
10
|
- pre
|
11
|
-
|
11
|
+
- 1
|
12
|
+
version: 1.1.12.pre.1
|
12
13
|
platform: ruby
|
13
14
|
authors:
|
14
15
|
- Noah Cantor
|