capistrano-ec2 0.1.4 → 0.1.5
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.
- checksums.yaml +4 -4
- data/lib/capistrano/ec2/capistrano_monkey_patch.rb +43 -9
- data/lib/capistrano/ec2/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a565dadc8f1f7ffba685488bf8a804a4633a2a18
|
4
|
+
data.tar.gz: be80c99f0570af72dd553571b079fdd08fe3fa72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff5558324541bf6832b335cb1f90fe189943bc91bd6b963f646ce6afad1e80e0be9744868d30e34351de31ac0b50739c07f0aea8258a6442739fc6536fe3b99f
|
7
|
+
data.tar.gz: 6484ea5bc858ff7d4adee69a0bef087c851f2bba5412280c9feba2af0dfa9ec156c2764df20ca252a3da44bcfa5e197447993fc12579face04c9881e09c9c978
|
@@ -3,15 +3,10 @@ require 'fog/aws'
|
|
3
3
|
module Capistrano
|
4
4
|
class Configuration
|
5
5
|
def for_each_ec2_server(ec2_env:, ec2_role:, &block)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
filters = {
|
12
|
-
"tag:ec2_env" => ec2_env,
|
13
|
-
"tag:role" => ec2_role,
|
14
|
-
'instance-state-name': 'running'
|
6
|
+
filters = {
|
7
|
+
'tag:ec2_env' => ec2_env,
|
8
|
+
'tag:role' => ec2_role,
|
9
|
+
'instance-state-name': 'running'
|
15
10
|
}
|
16
11
|
|
17
12
|
ec2.servers.all(filters).map.with_index do |ec2_server, index|
|
@@ -20,6 +15,45 @@ module Capistrano
|
|
20
15
|
yield ec2_server, index
|
21
16
|
end
|
22
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def ec2
|
22
|
+
@ec2 ||= Fog::Compute.new(fog_arguments)
|
23
|
+
end
|
24
|
+
|
25
|
+
def fog_arguments
|
26
|
+
default_options = {
|
27
|
+
provider: 'AWS',
|
28
|
+
region: region,
|
29
|
+
}
|
30
|
+
|
31
|
+
if use_iam_profile
|
32
|
+
default_options.merge(iam_profile_options)
|
33
|
+
else
|
34
|
+
default_options.merge(access_key_options)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def region
|
39
|
+
fetch(:region)
|
40
|
+
end
|
41
|
+
|
42
|
+
def use_iam_profile
|
43
|
+
fetch(:use_iam_profile, false)
|
44
|
+
end
|
45
|
+
|
46
|
+
def iam_profile_options
|
47
|
+
{ use_iam_profile: true }
|
48
|
+
end
|
49
|
+
|
50
|
+
def access_key_options
|
51
|
+
{
|
52
|
+
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
53
|
+
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
|
54
|
+
aws_session_token: ENV['AWS_SESSION_TOKEN'],
|
55
|
+
}
|
56
|
+
end
|
23
57
|
end
|
24
58
|
|
25
59
|
module DSL
|