capistrano-aws 1.0.1 → 1.1.0
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 +5 -5
- data/.gitignore +1 -0
- data/CHANGELOG.md +8 -0
- data/README.md +50 -1
- data/capistrano-aws.gemspec +3 -3
- data/lib/capistrano/aws/defaults.rb +10 -1
- data/lib/capistrano/aws/ec2/ec2.rb +3 -1
- data/lib/capistrano/aws/ec2/instances_table.rb +4 -2
- metadata +6 -7
- data/Gemfile.lock +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9a292ddac98e4d209192705dd84fb673078fc3e920431d3ee443fe4d46fb014c
|
4
|
+
data.tar.gz: 95b3803b24e7ea003c2b4df69b75306898d980e60caa8f94076141dd69431d94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78635604ddd07f9a0df3e6cfc9d9653c3af87380940b729431f94f2a1c73521475d0fd5685078a7d0075d5f0ac43ca1412a549e9fdec53765c399d31d4e673dd
|
7
|
+
data.tar.gz: 79d35c68f7bb28d24170c552d51e59d966e9bd1a78420b37aeffd88ed192c3e4a3edaa96086ba216a755bb1109a8a36808f3a0d8ff17611289f3c5bd6c8e24e7
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
2018-03-08 - 1.1.0 - Custom filters
|
2
|
+
|
3
|
+
* Support extra filters for retrieving EC2 instances.
|
4
|
+
* Allow customization of the stage filter value.
|
5
|
+
* Improved description of the :aws_ec2_roles_tag variable.
|
6
|
+
* Removed Gemfile.lock.
|
7
|
+
* Order instances by name in the instances table.
|
8
|
+
|
1
9
|
2017-05-05 - 1.0.1 - Improved instances access
|
2
10
|
|
3
11
|
* Turn instances result into a hash, being able to access the instance by its id.
|
data/README.md
CHANGED
@@ -35,15 +35,24 @@ set :aws_ec2_regions, ['us-east-1']
|
|
35
35
|
# Application name to match application tag.
|
36
36
|
set :aws_ec2_application, (proc { fetch(:application) })
|
37
37
|
|
38
|
+
# Stage to match stage tag.
|
39
|
+
set :aws_ec2_stage, (proc { fetch(:stage) })
|
40
|
+
|
38
41
|
# Tag to be used for Capistrano stage.
|
39
42
|
set :aws_ec2_stage_tag, 'Stage'
|
40
43
|
|
41
44
|
# Tag to be used to match the application.
|
42
45
|
set :aws_ec2_application_tag, 'Application'
|
43
46
|
|
44
|
-
# Tag to be used for Capistrano roles of the server (comma separated list).
|
47
|
+
# Tag to be used for Capistrano roles of the server (the tag value can be a comma separated list).
|
45
48
|
set :aws_ec2_roles_tag, 'Roles'
|
46
49
|
|
50
|
+
# Extra filters to be used to retrieve the instances. See the README.md for more information.
|
51
|
+
set :aws_ec2_extra_filters, []
|
52
|
+
|
53
|
+
# Tag to be used as the instance name in the instances table (aws:ec2:instances task).
|
54
|
+
set :aws_ec2_name_tag, 'Name'
|
55
|
+
|
47
56
|
# How to contact the instance (:public_ip, :public_dns, :private_ip).
|
48
57
|
set :aws_ec2_contact_point, :public_ip
|
49
58
|
```
|
@@ -64,6 +73,46 @@ It will use the instance tags to call the `server` function in capistrano. You c
|
|
64
73
|
aws_ec2_register user: 'hello', port: 2222
|
65
74
|
```
|
66
75
|
|
76
|
+
## Custom EC2 Filters
|
77
|
+
|
78
|
+
If you need to identify the instances based on more information, you can specify extra filters to be used in the `filters` option in the [Aws::EC2::Resource.instances](https://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Resource.html#instances-instance_method) call.
|
79
|
+
|
80
|
+
Imagine you have some split test servers for your production environment, so you can use another tag for specifying the variation of some servers:
|
81
|
+
|
82
|
+
| Name | Application | Environment | Roles | SplitTestVariation |
|
83
|
+
|-----------|-------------|-------------|--------|--------------------|
|
84
|
+
| foo-app01 | foo-app | production | app,db | 0 |
|
85
|
+
| foo-app02 | foo-app | production | app | 0 |
|
86
|
+
| foo-app03 | foo-app | production | app | 1 |
|
87
|
+
| foo-app04 | foo-app | production | app | 1 |
|
88
|
+
|
89
|
+
In your environment files:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
# production.rb
|
93
|
+
|
94
|
+
set :aws_ec2_extra_filters, [
|
95
|
+
{
|
96
|
+
name: "tag:SplitTestVariation",
|
97
|
+
values: ["0"],
|
98
|
+
},
|
99
|
+
]
|
100
|
+
```
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
# production-b.rb
|
104
|
+
|
105
|
+
set :aws_ec2_stage, "production" # Optional. Use if you have the same environment for the B servers.
|
106
|
+
set :aws_ec2_extra_filters, [
|
107
|
+
{
|
108
|
+
name: "tag:SplitTestVariation",
|
109
|
+
values: ["1"],
|
110
|
+
},
|
111
|
+
]
|
112
|
+
```
|
113
|
+
|
114
|
+
The `:aws_ec2_stage` variable is needed in order to override the default value of the stage fielter(`:stage`). If you really have a different environment for your `B` servers, you can just use the name of the environment as the file name and remove this line.
|
115
|
+
|
67
116
|
# Utility tasks
|
68
117
|
|
69
118
|
## aws:ec2:instances
|
data/capistrano-aws.gemspec
CHANGED
@@ -5,10 +5,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = 'capistrano-aws'
|
8
|
-
gem.version = '1.0
|
8
|
+
gem.version = '1.1.0'
|
9
9
|
gem.author = 'Fernando Carletti'
|
10
10
|
gem.email = 'contact@fernandocarletti.net'
|
11
|
-
gem.homepage = 'http://github.com/
|
11
|
+
gem.homepage = 'http://github.com/fernandocarletti/capistrano-aws'
|
12
12
|
gem.summary = 'Integrates capistrano with AWS.'
|
13
13
|
gem.description = 'Allow dynamically add servers based on EC2.'
|
14
14
|
|
@@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.add_dependency 'terminal-table', '~>1.7'
|
26
26
|
gem.add_dependency 'colorize', '~>0.8'
|
27
27
|
|
28
|
-
gem.add_development_dependency 'rubocop', '~>0.
|
28
|
+
gem.add_development_dependency 'rubocop', '~>0.53'
|
29
29
|
end
|
@@ -4,14 +4,23 @@ set :aws_ec2_regions, ['us-east-1']
|
|
4
4
|
# Application name to match application tag.
|
5
5
|
set :aws_ec2_application, (proc { fetch(:application) })
|
6
6
|
|
7
|
+
# Stage to match stage tag.
|
8
|
+
set :aws_ec2_stage, (proc { fetch(:stage) })
|
9
|
+
|
7
10
|
# Tag to be used for Capistrano stage.
|
8
11
|
set :aws_ec2_stage_tag, 'Stage'
|
9
12
|
|
10
13
|
# Tag to be used to match the application.
|
11
14
|
set :aws_ec2_application_tag, 'Application'
|
12
15
|
|
13
|
-
# Tag to be used for Capistrano roles of the server (comma separated list).
|
16
|
+
# Tag to be used for Capistrano roles of the server (the tag value can be a comma separated list).
|
14
17
|
set :aws_ec2_roles_tag, 'Roles'
|
15
18
|
|
19
|
+
# Extra filters to be used to retrieve the instances. See the README.md for more information.
|
20
|
+
set :aws_ec2_extra_filters, []
|
21
|
+
|
22
|
+
# Tag to be used as the instance name in the instances table (aws:ec2:instances task).
|
23
|
+
set :aws_ec2_name_tag, 'Name'
|
24
|
+
|
16
25
|
# How to contact the instance (:public_ip, :public_dns, :private_ip).
|
17
26
|
set :aws_ec2_contact_point, :public_ip
|
@@ -34,7 +34,7 @@ module Capistrano
|
|
34
34
|
},
|
35
35
|
{
|
36
36
|
name: "tag:#{fetch(:aws_ec2_stage_tag)}",
|
37
|
-
values: [fetch(:
|
37
|
+
values: [fetch(:aws_ec2_stage)]
|
38
38
|
},
|
39
39
|
{
|
40
40
|
name: 'instance-state-name',
|
@@ -42,6 +42,8 @@ module Capistrano
|
|
42
42
|
}
|
43
43
|
]
|
44
44
|
|
45
|
+
filters.concat fetch(:aws_ec2_extra_filters)
|
46
|
+
|
45
47
|
@ec2.each do |_region, client|
|
46
48
|
client.instances(filters: filters).each do |instance|
|
47
49
|
instances[instance.id] = instance
|
@@ -7,7 +7,9 @@ module Capistrano
|
|
7
7
|
# Generates instances table.
|
8
8
|
class InstancesTable
|
9
9
|
def initialize(instances)
|
10
|
-
@instances = instances
|
10
|
+
@instances = instances.sort_by do |_id, instance|
|
11
|
+
Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_name_tag))
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
def render
|
@@ -47,7 +49,7 @@ module Capistrano
|
|
47
49
|
[
|
48
50
|
format('%02d:', number),
|
49
51
|
instance.id.colorize(:red),
|
50
|
-
Capistrano::Aws::EC2.parse_tag(instance,
|
52
|
+
Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_name_tag)).colorize(:green),
|
51
53
|
instance.instance_type.colorize(:cyan),
|
52
54
|
Capistrano::Aws::EC2.contact_point(instance).colorize(:blue),
|
53
55
|
instance.placement.availability_zone.colorize(:magenta),
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Carletti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.53'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.53'
|
69
69
|
description: Allow dynamically add servers based on EC2.
|
70
70
|
email: contact@fernandocarletti.net
|
71
71
|
executables: []
|
@@ -77,7 +77,6 @@ files:
|
|
77
77
|
- ".rubocop.yml"
|
78
78
|
- CHANGELOG.md
|
79
79
|
- Gemfile
|
80
|
-
- Gemfile.lock
|
81
80
|
- LICENSE
|
82
81
|
- README.md
|
83
82
|
- capistrano-aws.gemspec
|
@@ -87,7 +86,7 @@ files:
|
|
87
86
|
- lib/capistrano/aws/ec2/instances_table.rb
|
88
87
|
- lib/capistrano/dsl/aws.rb
|
89
88
|
- lib/capistrano/tasks/ec2.rake
|
90
|
-
homepage: http://github.com/
|
89
|
+
homepage: http://github.com/fernandocarletti/capistrano-aws
|
91
90
|
licenses:
|
92
91
|
- MIT
|
93
92
|
metadata: {}
|
@@ -107,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
106
|
version: '0'
|
108
107
|
requirements: []
|
109
108
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.7.4
|
111
110
|
signing_key:
|
112
111
|
specification_version: 4
|
113
112
|
summary: Integrates capistrano with AWS.
|
data/Gemfile.lock
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
capistrano-aws (1.0.0)
|
5
|
-
aws-sdk (~> 2.9)
|
6
|
-
colorize (~> 0.8)
|
7
|
-
terminal-table (~> 1.7)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
ast (2.3.0)
|
13
|
-
aws-sdk (2.9.15)
|
14
|
-
aws-sdk-resources (= 2.9.15)
|
15
|
-
aws-sdk-core (2.9.15)
|
16
|
-
aws-sigv4 (~> 1.0)
|
17
|
-
jmespath (~> 1.0)
|
18
|
-
aws-sdk-resources (2.9.15)
|
19
|
-
aws-sdk-core (= 2.9.15)
|
20
|
-
aws-sigv4 (1.0.0)
|
21
|
-
colorize (0.8.1)
|
22
|
-
jmespath (1.3.1)
|
23
|
-
parser (2.4.0.0)
|
24
|
-
ast (~> 2.2)
|
25
|
-
powerpack (0.1.1)
|
26
|
-
rainbow (2.2.2)
|
27
|
-
rake
|
28
|
-
rake (12.0.0)
|
29
|
-
rubocop (0.48.1)
|
30
|
-
parser (>= 2.3.3.1, < 3.0)
|
31
|
-
powerpack (~> 0.1)
|
32
|
-
rainbow (>= 1.99.1, < 3.0)
|
33
|
-
ruby-progressbar (~> 1.7)
|
34
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
35
|
-
ruby-progressbar (1.8.1)
|
36
|
-
terminal-table (1.7.0)
|
37
|
-
unicode-display_width (~> 1.1)
|
38
|
-
unicode-display_width (1.2.1)
|
39
|
-
|
40
|
-
PLATFORMS
|
41
|
-
ruby
|
42
|
-
|
43
|
-
DEPENDENCIES
|
44
|
-
capistrano-aws!
|
45
|
-
rubocop (~> 0.48)
|
46
|
-
|
47
|
-
BUNDLED WITH
|
48
|
-
1.14.6
|