capistrano-aws 1.1.0 → 1.3.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 +4 -4
- data/.gitignore +1 -3
- data/CHANGELOG.md +8 -0
- data/README.md +12 -12
- data/capistrano-aws.gemspec +6 -5
- data/lib/capistrano/aws/ec2/ec2.rb +6 -18
- data/lib/capistrano/aws/ec2/instances_table.rb +16 -16
- data/lib/capistrano/aws.rb +2 -6
- data/lib/capistrano/dsl/aws.rb +1 -1
- data/lib/capistrano/tasks/defaults.rake +48 -0
- data/lib/capistrano-aws.rb +0 -0
- metadata +36 -16
- data/lib/capistrano/aws/defaults.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbec575475bb720dc8ca561f8e26c9cb2c1280bdc6535ae5bed01a709e506ab5
|
4
|
+
data.tar.gz: 741650bc0b0945fbbbb4df0394babe26bcc3791c0784e28d547b6841f227c3ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83eeab8d5f62b97858d0200cd50affcf0aad3c688cbcad5f2da06574ca1424b09c077e4cca6b28fb25fb96cf5e2e42e848cbbc5e700c94ecc5d0ec2f330a3773
|
7
|
+
data.tar.gz: ecf4f0433304eca8f38b31cd6005001de6079a4654c69afc3800df076b747fd3b684fb0434d81c885174f7d117bb9a299769d145c5dd3485953979fe486f8278
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
2021-11-10 - 1.3.0 - Fix License!
|
2
|
+
|
3
|
+
* Move from colorize to rainbow due to license incompatibiliy (Thanks @andyspix!)
|
4
|
+
|
5
|
+
2020-04-22 - 1.2.2 - Extra EC2 contact point
|
6
|
+
|
7
|
+
* Added extra EC2 contact point with instance id and private DNS (for SSM usage)
|
8
|
+
|
1
9
|
2018-03-08 - 1.1.0 - Custom filters
|
2
10
|
|
3
11
|
* Support extra filters for retrieving EC2 instances.
|
data/README.md
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
Capistrano AWS
|
2
|
-
==============
|
1
|
+
# Capistrano AWS [](https://badge.fury.io/rb/capistrano-aws)
|
3
2
|
|
4
3
|
This gem is slightly based on [cap-ec2](https://github.com/forward3d/cap-ec2), which is not maintained for a while, becoming outdated.
|
5
4
|
|
6
5
|
The purpose of this gem is to provide a flexible and simple integration to AWS EC2, exposing the aws-sdk connection in order to allow any customization.
|
7
6
|
|
8
|
-
|
7
|
+
## Requirements
|
9
8
|
|
10
9
|
* Capistrano 3
|
11
10
|
|
12
|
-
|
11
|
+
## Installation
|
13
12
|
|
14
13
|
Add to your `Gemfile` and run `bundler`:
|
15
14
|
```ruby
|
@@ -18,7 +17,7 @@ gem 'capistrano-aws'
|
|
18
17
|
|
19
18
|
Or install the gem system-wide:
|
20
19
|
```bash
|
21
|
-
gem install
|
20
|
+
gem install capistrano-aws
|
22
21
|
```
|
23
22
|
|
24
23
|
In your `Capfile`:
|
@@ -26,7 +25,7 @@ In your `Capfile`:
|
|
26
25
|
require 'capistrano/aws'
|
27
26
|
```
|
28
27
|
|
29
|
-
|
28
|
+
## Configuration
|
30
29
|
|
31
30
|
```ruby
|
32
31
|
# AWS regions to use.
|
@@ -53,16 +52,17 @@ set :aws_ec2_extra_filters, []
|
|
53
52
|
# Tag to be used as the instance name in the instances table (aws:ec2:instances task).
|
54
53
|
set :aws_ec2_name_tag, 'Name'
|
55
54
|
|
56
|
-
# How to contact the instance (:public_ip, :public_dns, :private_ip).
|
55
|
+
# How to contact the instance (:public_ip, :public_dns, :private_ip, :private_dns, :id).
|
57
56
|
set :aws_ec2_contact_point, :public_ip
|
58
57
|
```
|
59
58
|
|
60
59
|
The AWS credentials are loaded from your system. Check https://github.com/aws/aws-sdk-ruby#configuration for more information.
|
61
60
|
|
62
|
-
|
61
|
+
## Usage
|
63
62
|
|
64
63
|
The instances must be registered in each stage. In your `config/deploy/<stage_name>.rb`, add the following line:
|
65
64
|
|
65
|
+
*This must be placed after you have configured your AWS settings*
|
66
66
|
```ruby
|
67
67
|
aws_ec2_register
|
68
68
|
```
|
@@ -73,7 +73,7 @@ It will use the instance tags to call the `server` function in capistrano. You c
|
|
73
73
|
aws_ec2_register user: 'hello', port: 2222
|
74
74
|
```
|
75
75
|
|
76
|
-
|
76
|
+
### Custom EC2 Filters
|
77
77
|
|
78
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
79
|
|
@@ -113,9 +113,9 @@ set :aws_ec2_extra_filters, [
|
|
113
113
|
|
114
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
115
|
|
116
|
-
|
116
|
+
## Utility tasks
|
117
117
|
|
118
|
-
|
118
|
+
### aws:ec2:instances
|
119
119
|
|
120
120
|
List all the instances found for with the current configuration.
|
121
121
|
|
@@ -123,6 +123,6 @@ List all the instances found for with the current configuration.
|
|
123
123
|
cap production aws:ec2:instances
|
124
124
|
```
|
125
125
|
|
126
|
-
|
126
|
+
## Contributing
|
127
127
|
|
128
128
|
Open an issue or make a PR, feel free to contribute!
|
data/capistrano-aws.gemspec
CHANGED
@@ -5,7 +5,7 @@ $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.
|
8
|
+
gem.version = '1.3.0'
|
9
9
|
gem.author = 'Fernando Carletti'
|
10
10
|
gem.email = 'contact@fernandocarletti.net'
|
11
11
|
gem.homepage = 'http://github.com/fernandocarletti/capistrano-aws'
|
@@ -21,9 +21,10 @@ Gem::Specification.new do |gem|
|
|
21
21
|
|
22
22
|
gem.required_ruby_version = '>= 2.0'
|
23
23
|
|
24
|
-
gem.add_dependency '
|
25
|
-
gem.add_dependency '
|
26
|
-
gem.add_dependency '
|
24
|
+
gem.add_dependency 'capistrano', '~> 3.1'
|
25
|
+
gem.add_dependency 'aws-sdk-ec2', '~> 1'
|
26
|
+
gem.add_dependency 'terminal-table', '>= 1.7', '< 4.0'
|
27
|
+
gem.add_dependency 'rainbow', '~> 3'
|
27
28
|
|
28
|
-
gem.add_development_dependency 'rubocop', '~>0.53'
|
29
|
+
gem.add_development_dependency 'rubocop', '~> 0.53'
|
29
30
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'singleton'
|
2
|
-
require 'aws-sdk'
|
2
|
+
require 'aws-sdk-ec2'
|
3
3
|
|
4
4
|
module Capistrano
|
5
5
|
module Aws
|
@@ -22,25 +22,9 @@ module Capistrano
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def instances
|
25
|
-
application = fetch(:aws_ec2_application)
|
26
|
-
raise 'application not set.' if application.nil?
|
27
|
-
|
28
25
|
instances = {}
|
29
26
|
|
30
|
-
filters =
|
31
|
-
{
|
32
|
-
name: "tag:#{fetch(:aws_ec2_application_tag)}",
|
33
|
-
values: [fetch(:aws_ec2_application)]
|
34
|
-
},
|
35
|
-
{
|
36
|
-
name: "tag:#{fetch(:aws_ec2_stage_tag)}",
|
37
|
-
values: [fetch(:aws_ec2_stage)]
|
38
|
-
},
|
39
|
-
{
|
40
|
-
name: 'instance-state-name',
|
41
|
-
values: ['running']
|
42
|
-
}
|
43
|
-
]
|
27
|
+
filters = fetch(:aws_ec2_default_filters)
|
44
28
|
|
45
29
|
filters.concat fetch(:aws_ec2_extra_filters)
|
46
30
|
|
@@ -58,6 +42,10 @@ module Capistrano
|
|
58
42
|
case fetch(:aws_ec2_contact_point)
|
59
43
|
when :private_ip
|
60
44
|
instance.private_ip_address
|
45
|
+
when :private_dns
|
46
|
+
instance.private_dns_name
|
47
|
+
when :id
|
48
|
+
instance.id
|
61
49
|
when :public_dns
|
62
50
|
instance.public_dns_name
|
63
51
|
else
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'terminal-table'
|
2
|
-
require '
|
2
|
+
require 'rainbow'
|
3
3
|
|
4
4
|
module Capistrano
|
5
5
|
module Aws
|
@@ -34,27 +34,27 @@ module Capistrano
|
|
34
34
|
|
35
35
|
def header_row
|
36
36
|
[
|
37
|
-
'Num'.
|
38
|
-
'ID'.
|
39
|
-
'Name'.
|
40
|
-
'Type'.
|
41
|
-
'Contact Point'.
|
42
|
-
'Availability Zone'.
|
43
|
-
'Roles'.
|
44
|
-
'Stages'.
|
37
|
+
Rainbow('Num').bright,
|
38
|
+
Rainbow('ID').bright,
|
39
|
+
Rainbow('Name').bright,
|
40
|
+
Rainbow('Type').bright,
|
41
|
+
Rainbow('Contact Point').bright,
|
42
|
+
Rainbow('Availability Zone').bright,
|
43
|
+
Rainbow('Roles').bright,
|
44
|
+
Rainbow('Stages').bright
|
45
45
|
]
|
46
46
|
end
|
47
47
|
|
48
48
|
def instance_row(number, instance)
|
49
49
|
[
|
50
50
|
format('%02d:', number),
|
51
|
-
instance.id.
|
52
|
-
Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_name_tag)).
|
53
|
-
instance.instance_type.
|
54
|
-
Capistrano::Aws::EC2.contact_point(instance).
|
55
|
-
instance.placement.availability_zone.
|
56
|
-
Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_roles_tag)).
|
57
|
-
Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_stage_tag)).
|
51
|
+
Rainbow(instance.id).red,
|
52
|
+
Rainbow(Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_name_tag))).green,
|
53
|
+
Rainbow(instance.instance_type).cyan,
|
54
|
+
Rainbow(Capistrano::Aws::EC2.contact_point(instance)).blue,
|
55
|
+
Rainbow(instance.placement.availability_zone).magenta,
|
56
|
+
Rainbow(Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_roles_tag))).yellow,
|
57
|
+
Rainbow(Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_stage_tag))).yellow
|
58
58
|
]
|
59
59
|
end
|
60
60
|
end
|
data/lib/capistrano/aws.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
require 'capistrano/aws/ec2/ec2'
|
2
2
|
require 'capistrano/dsl/aws'
|
3
|
+
|
3
4
|
extend Capistrano::DSL::Aws
|
4
5
|
|
5
6
|
SSHKit::Backend::Netssh.send(:include, Capistrano::DSL::Aws)
|
6
7
|
|
7
8
|
load File.expand_path('../tasks/ec2.rake', __FILE__)
|
8
|
-
|
9
|
-
namespace :load do
|
10
|
-
task :defaults do
|
11
|
-
load 'capistrano/aws/defaults.rb'
|
12
|
-
end
|
13
|
-
end
|
9
|
+
load File.expand_path("../tasks/defaults.rake", __FILE__)
|
data/lib/capistrano/dsl/aws.rb
CHANGED
@@ -9,7 +9,7 @@ module Capistrano
|
|
9
9
|
def aws_ec2_register(options = {})
|
10
10
|
aws_ec2.instances.each do |_id, instance|
|
11
11
|
ip = Capistrano::Aws::EC2.contact_point(instance)
|
12
|
-
roles = Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_roles_tag)).split(
|
12
|
+
roles = Capistrano::Aws::EC2.parse_tag(instance, fetch(:aws_ec2_roles_tag)).split(",").map(&:strip)
|
13
13
|
|
14
14
|
server ip, options.merge(roles: roles, aws_instance_id: instance.id)
|
15
15
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
namespace :load do
|
2
|
+
task :defaults do
|
3
|
+
# AWS regions to use.
|
4
|
+
set :aws_ec2_regions, ['us-east-1']
|
5
|
+
|
6
|
+
# Application name to match application tag.
|
7
|
+
set :aws_ec2_application, (proc { fetch(:application) })
|
8
|
+
|
9
|
+
# Stage to match stage tag.
|
10
|
+
set :aws_ec2_stage, (proc { fetch(:stage) })
|
11
|
+
|
12
|
+
# Tag to be used for Capistrano stage.
|
13
|
+
set :aws_ec2_stage_tag, 'Stage'
|
14
|
+
|
15
|
+
# Tag to be used to match the application.
|
16
|
+
set :aws_ec2_application_tag, 'Application'
|
17
|
+
|
18
|
+
# Tag to be used for Capistrano roles of the server (the tag value can be a comma separated list).
|
19
|
+
set :aws_ec2_roles_tag, 'Roles'
|
20
|
+
|
21
|
+
# Default filters used for all requests, set to an empty array [] to disable completely
|
22
|
+
set :aws_ec2_default_filters, (proc {
|
23
|
+
[
|
24
|
+
{
|
25
|
+
name: "tag:#{fetch(:aws_ec2_application_tag)}",
|
26
|
+
values: [fetch(:aws_ec2_application)]
|
27
|
+
},
|
28
|
+
{
|
29
|
+
name: "tag:#{fetch(:aws_ec2_stage_tag)}",
|
30
|
+
values: [fetch(:aws_ec2_stage)]
|
31
|
+
},
|
32
|
+
{
|
33
|
+
name: 'instance-state-name',
|
34
|
+
values: ['running']
|
35
|
+
}
|
36
|
+
]
|
37
|
+
})
|
38
|
+
|
39
|
+
# Extra filters to be used to retrieve the instances. See the README.md for more information.
|
40
|
+
set :aws_ec2_extra_filters, []
|
41
|
+
|
42
|
+
# Tag to be used as the instance name in the instances table (aws:ec2:instances task).
|
43
|
+
set :aws_ec2_name_tag, 'Name'
|
44
|
+
|
45
|
+
# How to contact the instance (:public_ip, :public_dns, :private_ip, :private_dns, :id).
|
46
|
+
set :aws_ec2_contact_point, :public_ip
|
47
|
+
end
|
48
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,57 +1,77 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Carletti
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: capistrano
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: aws-sdk-ec2
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
33
|
+
version: '1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: terminal-table
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
39
46
|
- !ruby/object:Gem::Version
|
40
47
|
version: '1.7'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '4.0'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '1.7'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '4.0'
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
62
|
+
name: rainbow
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
44
64
|
requirements:
|
45
65
|
- - "~>"
|
46
66
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
67
|
+
version: '3'
|
48
68
|
type: :runtime
|
49
69
|
prerelease: false
|
50
70
|
version_requirements: !ruby/object:Gem::Requirement
|
51
71
|
requirements:
|
52
72
|
- - "~>"
|
53
73
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
74
|
+
version: '3'
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
76
|
name: rubocop
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,17 +100,18 @@ files:
|
|
80
100
|
- LICENSE
|
81
101
|
- README.md
|
82
102
|
- capistrano-aws.gemspec
|
103
|
+
- lib/capistrano-aws.rb
|
83
104
|
- lib/capistrano/aws.rb
|
84
|
-
- lib/capistrano/aws/defaults.rb
|
85
105
|
- lib/capistrano/aws/ec2/ec2.rb
|
86
106
|
- lib/capistrano/aws/ec2/instances_table.rb
|
87
107
|
- lib/capistrano/dsl/aws.rb
|
108
|
+
- lib/capistrano/tasks/defaults.rake
|
88
109
|
- lib/capistrano/tasks/ec2.rake
|
89
110
|
homepage: http://github.com/fernandocarletti/capistrano-aws
|
90
111
|
licenses:
|
91
112
|
- MIT
|
92
113
|
metadata: {}
|
93
|
-
post_install_message:
|
114
|
+
post_install_message:
|
94
115
|
rdoc_options: []
|
95
116
|
require_paths:
|
96
117
|
- lib
|
@@ -105,9 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
126
|
- !ruby/object:Gem::Version
|
106
127
|
version: '0'
|
107
128
|
requirements: []
|
108
|
-
|
109
|
-
|
110
|
-
signing_key:
|
129
|
+
rubygems_version: 3.2.21
|
130
|
+
signing_key:
|
111
131
|
specification_version: 4
|
112
132
|
summary: Integrates capistrano with AWS.
|
113
133
|
test_files: []
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# AWS regions to use.
|
2
|
-
set :aws_ec2_regions, ['us-east-1']
|
3
|
-
|
4
|
-
# Application name to match application tag.
|
5
|
-
set :aws_ec2_application, (proc { fetch(:application) })
|
6
|
-
|
7
|
-
# Stage to match stage tag.
|
8
|
-
set :aws_ec2_stage, (proc { fetch(:stage) })
|
9
|
-
|
10
|
-
# Tag to be used for Capistrano stage.
|
11
|
-
set :aws_ec2_stage_tag, 'Stage'
|
12
|
-
|
13
|
-
# Tag to be used to match the application.
|
14
|
-
set :aws_ec2_application_tag, 'Application'
|
15
|
-
|
16
|
-
# Tag to be used for Capistrano roles of the server (the tag value can be a comma separated list).
|
17
|
-
set :aws_ec2_roles_tag, 'Roles'
|
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
|
-
|
25
|
-
# How to contact the instance (:public_ip, :public_dns, :private_ip).
|
26
|
-
set :aws_ec2_contact_point, :public_ip
|