capify-ec2 1.4.5 → 1.4.6
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 +6 -0
- data/lib/capify-ec2.rb +14 -6
- data/lib/capify-ec2/version.rb +1 -1
- data/readme.md +14 -6
- metadata +3 -3
data/Changelog.md
CHANGED
data/lib/capify-ec2.rb
CHANGED
@@ -34,9 +34,9 @@ class CapifyEc2
|
|
34
34
|
|
35
35
|
@instances = []
|
36
36
|
regions.each do |region|
|
37
|
-
Fog::Compute.new(:provider => 'AWS',
|
38
|
-
:aws_access_key_id =>
|
39
|
-
:aws_secret_access_key =>
|
37
|
+
Fog::Compute.new(:provider => 'AWS',
|
38
|
+
:aws_access_key_id => aws_access_key_id,
|
39
|
+
:aws_secret_access_key => aws_secret_access_key,
|
40
40
|
:region => region).servers.each do |server|
|
41
41
|
@instances << server if server.ready?
|
42
42
|
end
|
@@ -46,7 +46,15 @@ class CapifyEc2
|
|
46
46
|
def determine_regions()
|
47
47
|
@ec2_config[:aws_params][:regions] || [@ec2_config[:aws_params][:region]]
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
|
+
def aws_access_key_id
|
51
|
+
@ec2_config[:aws_access_key_id] || ENV['AWS_ACCESS_KEY_ID']
|
52
|
+
end
|
53
|
+
|
54
|
+
def aws_secret_access_key
|
55
|
+
@ec2_config[:aws_secret_access_key] || ENV['AWS_SECRET_ACCESS_KEY']
|
56
|
+
end
|
57
|
+
|
50
58
|
def display_instances
|
51
59
|
unless desired_instances and desired_instances.any?
|
52
60
|
puts "[Capify-EC2] No instances were found using your 'ec2.yml' configuration.".red.bold
|
@@ -121,7 +129,7 @@ class CapifyEc2
|
|
121
129
|
end
|
122
130
|
|
123
131
|
def elb
|
124
|
-
Fog::AWS::ELB.new(:aws_access_key_id =>
|
132
|
+
Fog::AWS::ELB.new(:aws_access_key_id => aws_access_key_id, :aws_secret_access_key => aws_secret_access_key, :region => @ec2_config[:aws_params][:region])
|
125
133
|
end
|
126
134
|
|
127
135
|
def get_load_balancer_by_instance(instance_id)
|
@@ -276,4 +284,4 @@ class CapifyEC2RollingDeployError < Exception
|
|
276
284
|
super(msg)
|
277
285
|
@dns = dns
|
278
286
|
end
|
279
|
-
end
|
287
|
+
end
|
data/lib/capify-ec2/version.rb
CHANGED
data/readme.md
CHANGED
@@ -31,11 +31,11 @@ require "capify-ec2/capistrano"
|
|
31
31
|
|
32
32
|
#### Configuration
|
33
33
|
|
34
|
-
Note: 'aws_access_key_id', 'aws_secret_access_key', and 'region' are required. Other settings are optional.
|
34
|
+
Note: ':aws_access_key_id', ':aws_secret_access_key', and ':region' are required. Other settings are optional.
|
35
35
|
|
36
36
|
* :project_tag
|
37
37
|
|
38
|
-
If this is defined, Capify-EC2 will only create namespaces and tasks for the EC2 instances that have a matching 'Project' tag. By default, all instances available to the
|
38
|
+
If this is defined, Capify-EC2 will only create namespaces and tasks for the EC2 instances that have a matching 'Project' tag. By default, all instances available to the specified AWS access key will be used.
|
39
39
|
|
40
40
|
It is possible to include multiple projects simultaneously by using the :project_tags parameter, like so:
|
41
41
|
|
@@ -58,6 +58,10 @@ Note: 'aws_access_key_id', 'aws_secret_access_key', and 'region' are required. O
|
|
58
58
|
|
59
59
|
Use this option to change which EC2 instance tag Capify-EC2 uses to determine instance options. Defaults to 'Options' if ommited.
|
60
60
|
|
61
|
+
##### Via Environment Variables
|
62
|
+
|
63
|
+
If you wish, you can define AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables, instead of specifying ':aws_access_key_id' and ':aws_secret_access_key' in the YML configuration file.
|
64
|
+
|
61
65
|
|
62
66
|
|
63
67
|
#### EC2 Tags
|
@@ -75,9 +79,6 @@ You will need to create instance tags using the AWS Management Console or API, t
|
|
75
79
|
* Tag 'Options'
|
76
80
|
|
77
81
|
A comma seperated list of options which will be defined as 'true' for that instance. See the 'Options' section below for more information on their use.
|
78
|
-
task :bob, :only => {:option_nmame => true}
|
79
|
-
on_no_matching_servers => :continue
|
80
|
-
"one of those ten is cron" etc.
|
81
82
|
|
82
83
|
|
83
84
|
|
@@ -159,6 +160,7 @@ end
|
|
159
160
|
```
|
160
161
|
|
161
162
|
|
163
|
+
|
162
164
|
#### Multiple Roles
|
163
165
|
|
164
166
|
If you want to create tasks for servers using multiple roles, you can call 'ec2_roles' multiple times in your 'deploy.rb' as follows:
|
@@ -257,11 +259,17 @@ For example, if we had the following group of instances in EC2:
|
|
257
259
|
You could then create a task in your 'deploy.rb' that will only be executed on the worker machine, like so:
|
258
260
|
|
259
261
|
```ruby
|
260
|
-
task :reload_workers
|
262
|
+
task :reload_workers, :only=>{:worker=>true} do
|
261
263
|
# Do something to a specific server with the 'worker' option in it's EC2 tags.
|
262
264
|
end
|
263
265
|
```
|
264
266
|
|
267
|
+
```ruby
|
268
|
+
task :reload_workers, :roles => :app, :only=>{:worker=>true} do
|
269
|
+
# Do something to a specific 'app' server with the 'worker' option in it's EC2 tags.
|
270
|
+
end
|
271
|
+
```
|
272
|
+
|
265
273
|
##### Via Role Definitions
|
266
274
|
|
267
275
|
As well as defining Options at an instance level via EC2 tags, you can define an Option in your 'deploy.rb' at the same time as defining the role, as follows:
|
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: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 6
|
10
|
+
version: 1.4.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Noah Cantor
|