capistrano-ec2filter 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +87 -0
- data/Rakefile +1 -0
- data/capistrano-ec2filter.gemspec +23 -0
- data/lib/capistrano/ec2filter.rb +42 -0
- data/lib/capistrano/ec2filter/version.rb +5 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 780dd08d23ab6e157d524ed5804a80f58b20aa9b
|
4
|
+
data.tar.gz: c891cdf96a529e5f5458903c8e7312f5661335b4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 078ccfb75101d75f811f35930c26343f9ad248d39df3569ee0fb2571b59bb0952580ce27f9facad3964e23c32d51b5402075ce2908f7be2f43f57a8b172f4287
|
7
|
+
data.tar.gz: 2c5457f06d99f6fa7630d1365d68f9be1251a8da2c7315d8888eed87f26b2bc3d73d3fd99a42db35836860c693c9b1e7f38fa1056ca64a1b8a265dffc9371889
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Michał Rogowski
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Introduction
|
2
|
+
|
3
|
+
capistrano-ec2filter is a Capistrano plugin designed to simplify the task of deploying to infrastructure hosted on Amazon EC2.
|
4
|
+
It allows to declare capistrano deploy servers filtered with `ec2-describe-instances` criteria ([read more](#supported-filters)).
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'capistrano-ec2filter'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install capistrano-ec2filter
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Add this to the top of your `deploy.rb`:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require 'capistrano/ec2filter'
|
26
|
+
```
|
27
|
+
|
28
|
+
Then supply your AWS credentials with the environment variables (default):
|
29
|
+
|
30
|
+
```zsh
|
31
|
+
# aws
|
32
|
+
export AWS_ACCESS_KEY_ID='...'
|
33
|
+
export AWS_SECRET_ACCESS_KEY='...'
|
34
|
+
# export AWS_EC2_ENDPOINT='...'
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
Or in your `deploy.rb` with capistrano variables:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
set :aws_access_key_id, "..."
|
42
|
+
set :aws_secret_access_key, "..."
|
43
|
+
# set :aws_ec2_endpoint, "ec2.eu-west-1.amazonaws.com"
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
Define your servers:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
ec2_group("tag:application"=>"SuperApp", "tag:layer"=>"application") do |address|
|
51
|
+
server address, :web, :app
|
52
|
+
end
|
53
|
+
|
54
|
+
ec2_group("tag:application"=>"SuperApp", "tag:layer"=>"workers") do |address, instance|
|
55
|
+
server address, :app, :jobs, :min_job_priority: 10
|
56
|
+
end
|
57
|
+
|
58
|
+
ec2_group("placement-group-name"=>"matrix") do |address, instance|
|
59
|
+
server address, :matrix, platform: instance.platform
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
`instance` - [AWS::EC2::Instance](http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/Instance.html) from AWS SDK for Ruby
|
64
|
+
|
65
|
+
`address` - dns/ip address of instance = `instance.dns_name || instance.ip_address || instance.private_ip_address`
|
66
|
+
|
67
|
+
By default ec2_group apply `"instance-state-name" => "running"` filter. You can overwrite this:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
ec2_group("instance-state-name" => ["stopped", "stopping"], "tag:layer"=>"application") do |address|
|
71
|
+
server address, :app, stopped: true
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
### Supported filters
|
77
|
+
|
78
|
+
Full list of supported EC2 filters: [click here](http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-DescribeInstances.html#cmd-DescribeInstances-filters)
|
79
|
+
|
80
|
+
|
81
|
+
## Contributing
|
82
|
+
|
83
|
+
1. Fork it ( http://github.com/rogal111/capistrano-ec2filter/fork )
|
84
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
85
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
86
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
87
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/ec2filter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capistrano-ec2filter"
|
8
|
+
spec.version = Capistrano::Ec2filter::VERSION
|
9
|
+
spec.authors = ["Michał Rogowski"]
|
10
|
+
spec.email = ["michal.rogowski1@gmail.com"]
|
11
|
+
spec.summary = %q{Get DNS/ip addresses of AWS EC2 instances filtered by custom criteria}
|
12
|
+
spec.description = %q{Get DNS/ip addresses of AWS EC2 instances filtered by custom criteria (tag, name, status etc)}
|
13
|
+
spec.homepage = "https://github.com/rogal111/capistrano-ec2filter"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "capistrano", "~>2.1"
|
22
|
+
spec.add_dependency "aws-sdk", "~>1.3"
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "capistrano/ec2filter/version"
|
2
|
+
require "aws-sdk"
|
3
|
+
|
4
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
5
|
+
abort "capistrano/ec2filter requires Capistrano 2"
|
6
|
+
end
|
7
|
+
|
8
|
+
module Capistrano
|
9
|
+
module Ec2filter
|
10
|
+
def self.load_into(configuration)
|
11
|
+
configuration.load do
|
12
|
+
_cset(:aws_access_key_id, ENV["AWS_ACCESS_KEY_ID"])
|
13
|
+
_cset(:aws_secret_access_key, ENV["AWS_SECRET_ACCESS_KEY"])
|
14
|
+
_cset(:aws_ec2_endpoint, ENV["AWS_EC2_ENDPOINT"])
|
15
|
+
|
16
|
+
def ec2_group(filters = {})
|
17
|
+
filters = { "instance-state-name" => "running" }.merge(filters)
|
18
|
+
@aws_ec2 ||= AWS::EC2.new(
|
19
|
+
access_key_id: fetch(:aws_access_key_id),
|
20
|
+
secret_access_key: fetch(:aws_secret_access_key),
|
21
|
+
ec2_endpoint: fetch(:aws_ec2_endpoint)
|
22
|
+
)
|
23
|
+
|
24
|
+
instances = @aws_ec2.instances
|
25
|
+
|
26
|
+
filters.each do |attribute, value|
|
27
|
+
instances = instances.filter(attribute, value)
|
28
|
+
end
|
29
|
+
|
30
|
+
instances.each do |instance|
|
31
|
+
address = instance.dns_name || instance.ip_address || instance.private_ip_address
|
32
|
+
yield address, instance
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
if Capistrano::Configuration.instance
|
41
|
+
Capistrano::Ec2filter.load_into(Capistrano::Configuration.instance)
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-ec2filter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michał Rogowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
description: Get DNS/ip addresses of AWS EC2 instances filtered by custom criteria
|
42
|
+
(tag, name, status etc)
|
43
|
+
email:
|
44
|
+
- michal.rogowski1@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- capistrano-ec2filter.gemspec
|
55
|
+
- lib/capistrano/ec2filter.rb
|
56
|
+
- lib/capistrano/ec2filter/version.rb
|
57
|
+
homepage: https://github.com/rogal111/capistrano-ec2filter
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.2.0
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Get DNS/ip addresses of AWS EC2 instances filtered by custom criteria
|
81
|
+
test_files: []
|
82
|
+
has_rdoc:
|