capify-ec2 1.3.6 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +5 -0
- data/lib/capify-ec2.rb +10 -10
- data/lib/capify-ec2/capistrano.rb +13 -12
- data/lib/capify-ec2/version.rb +1 -1
- metadata +58 -74
data/Changelog.md
CHANGED
data/lib/capify-ec2.rb
CHANGED
@@ -3,7 +3,6 @@ require 'fog'
|
|
3
3
|
require 'colored'
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/capify-ec2/server')
|
5
5
|
|
6
|
-
|
7
6
|
class CapifyEc2
|
8
7
|
|
9
8
|
attr_accessor :load_balancer, :instances
|
@@ -18,23 +17,24 @@ class CapifyEc2
|
|
18
17
|
@ec2_config = ec2_config
|
19
18
|
when String
|
20
19
|
@ec2_config = YAML.load_file ec2_config
|
21
|
-
|
22
|
-
# Maintain backward compatibility with previous config format
|
23
|
-
@ec2_config[:project_tags] ||= []
|
24
|
-
# User can change the Roles tag string
|
25
|
-
@ec2_config[:aws_roles_tag] ||= "Roles"
|
26
|
-
@ec2_config[:project_tags] << @ec2_config[:project_tag] if @ec2_config[:project_tag]
|
27
20
|
else
|
28
21
|
raise ArgumentError, "Invalid ec2_config: #{ec2_config.inspect}"
|
29
22
|
end
|
30
23
|
|
24
|
+
# Maintain backward compatibility with previous config format
|
25
|
+
@ec2_config[:project_tags] ||= []
|
26
|
+
# User can change the Roles tag string
|
27
|
+
@ec2_config[:aws_roles_tag] ||= "Roles"
|
28
|
+
@ec2_config[:project_tags] << @ec2_config[:project_tag] if @ec2_config[:project_tag]
|
29
|
+
|
31
30
|
regions = determine_regions()
|
32
31
|
|
33
32
|
@instances = []
|
34
33
|
regions.each do |region|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
Fog::Compute.new(:provider => 'AWS',
|
35
|
+
:aws_access_key_id => @ec2_config[:aws_access_key_id],
|
36
|
+
:aws_secret_access_key => @ec2_config[:aws_secret_access_key],
|
37
|
+
:region => region).servers.each do |server|
|
38
38
|
@instances << server if server.ready?
|
39
39
|
end
|
40
40
|
end
|
@@ -77,23 +77,22 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def ec2_role(role_name_or_hash)
|
80
|
-
role
|
81
|
-
variables = role_name_or_hash[:variables] || {}
|
80
|
+
role = role_name_or_hash.is_a?(Hash) ? role_name_or_hash : {:name => role_name_or_hash, :options => {}, :variables => {}}
|
82
81
|
|
83
82
|
instances = capify_ec2.get_instances_by_role(role[:name])
|
84
|
-
|
85
83
|
if role[:options] && role[:options].delete(:default)
|
86
84
|
instances.each do |instance|
|
87
85
|
define_role(role, instance)
|
88
86
|
end
|
89
|
-
end
|
87
|
+
end
|
88
|
+
|
90
89
|
regions = capify_ec2.determine_regions
|
91
90
|
regions.each do |region|
|
92
91
|
define_regions(region, role)
|
93
92
|
end unless regions.nil?
|
94
93
|
|
95
|
-
define_role_roles(role, instances
|
96
|
-
define_instance_roles(role, instances
|
94
|
+
define_role_roles(role, instances)
|
95
|
+
define_instance_roles(role, instances)
|
97
96
|
end
|
98
97
|
|
99
98
|
def define_regions(region, role)
|
@@ -110,26 +109,27 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
|
-
def define_instance_roles(role, instances
|
112
|
+
def define_instance_roles(role, instances)
|
114
113
|
instances.each do |instance|
|
115
114
|
task instance.name.to_sym do
|
116
115
|
remove_default_roles
|
117
|
-
define_role(role, instance
|
116
|
+
define_role(role, instance)
|
118
117
|
end
|
119
118
|
end
|
120
119
|
end
|
121
120
|
|
122
|
-
def define_role_roles(role, instances
|
121
|
+
def define_role_roles(role, instances)
|
123
122
|
task role[:name].to_sym do
|
124
123
|
remove_default_roles
|
125
124
|
instances.each do |instance|
|
126
|
-
define_role(role, instance
|
125
|
+
define_role(role, instance)
|
127
126
|
end
|
128
127
|
end
|
129
128
|
end
|
130
129
|
|
131
|
-
def define_role(role, instance
|
130
|
+
def define_role(role, instance)
|
132
131
|
options = role[:options] || {}
|
132
|
+
variables = role[:variables] || {}
|
133
133
|
|
134
134
|
cap_options = options.inject({}) do |cap_options, (key, value)|
|
135
135
|
cap_options[key] = true if value.to_s == instance.name
|
@@ -139,7 +139,8 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
139
139
|
ec2_options = instance.tags["Options"] || ""
|
140
140
|
ec2_options.split(%r{,\s*}).compact.each { |ec2_option| cap_options[ec2_option.to_sym] = true }
|
141
141
|
|
142
|
-
variables.each { |
|
142
|
+
variables.each { |key, value| set key, value }
|
143
|
+
|
143
144
|
role role[:name].to_sym, instance.contact_point, cap_options
|
144
145
|
end
|
145
146
|
|
data/lib/capify-ec2/version.rb
CHANGED
metadata
CHANGED
@@ -1,79 +1,73 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: capify-ec2
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.7
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 3
|
9
|
-
- 6
|
10
|
-
version: 1.3.6
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Noah Cantor
|
14
9
|
- Siddharth Dawara
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2013-01-20 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: fog
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
25
18
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 25
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 3
|
33
|
-
- 1
|
19
|
+
requirements:
|
20
|
+
- - '='
|
21
|
+
- !ruby/object:Gem::Version
|
34
22
|
version: 1.3.1
|
35
23
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: colored
|
39
24
|
prerelease: false
|
40
|
-
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - '='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.3.1
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: colored
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
41
34
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 2
|
49
|
-
version: "1.2"
|
35
|
+
requirements:
|
36
|
+
- - '='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '1.2'
|
50
39
|
type: :runtime
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: capistrano
|
54
40
|
prerelease: false
|
55
|
-
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - '='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.2'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: capistrano
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
56
50
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
64
55
|
type: :runtime
|
65
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
66
63
|
description: Grabs roles from ec2's tags and autogenerates capistrano tasks
|
67
|
-
email:
|
64
|
+
email:
|
68
65
|
- noah.cantor@forward.co.uk
|
69
66
|
- siddharth.dawara@forward.co.uk
|
70
67
|
executables: []
|
71
|
-
|
72
68
|
extensions: []
|
73
|
-
|
74
69
|
extra_rdoc_files: []
|
75
|
-
|
76
|
-
files:
|
70
|
+
files:
|
77
71
|
- .gitignore
|
78
72
|
- Changelog.md
|
79
73
|
- Gemfile
|
@@ -87,36 +81,26 @@ files:
|
|
87
81
|
- readme.md
|
88
82
|
homepage: http://github.com/forward/capify-ec2
|
89
83
|
licenses: []
|
90
|
-
|
91
84
|
post_install_message:
|
92
85
|
rdoc_options: []
|
93
|
-
|
94
|
-
require_paths:
|
86
|
+
require_paths:
|
95
87
|
- lib
|
96
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
89
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
103
|
-
- 0
|
104
|
-
version: "0"
|
105
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
95
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
111
|
-
segments:
|
112
|
-
- 0
|
113
|
-
version: "0"
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
114
100
|
requirements: []
|
115
|
-
|
116
101
|
rubyforge_project: capify-ec2
|
117
|
-
rubygems_version: 1.8.
|
102
|
+
rubygems_version: 1.8.23
|
118
103
|
signing_key:
|
119
104
|
specification_version: 3
|
120
105
|
summary: Grabs roles from ec2's tags and autogenerates capistrano tasks
|
121
106
|
test_files: []
|
122
|
-
|