capistrano-asgroup 0.0.1

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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-asgroup.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2013 by Thomas Verbiscer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,99 @@
1
+ ## Introduction
2
+
3
+ capistrano-asgroup is a [Capistrano](https://github.com/capistrano/capistrano) plugin designed to simplify the
4
+ task of deploying to infrastructure hosted on [Amazon EC2](http://aws.amazon.com/ec2/). It was
5
+ completely inspired by the [capistrano-ec2group](https://github.com/logandk/capistrano-ec2group) and
6
+ [capistrano-ec2tag](https://github.com/douglasjarquin/capistrano-ec2tag) plugins, to which all credit is due.
7
+
8
+ Both of the prior plugins gave you "a way" to deploy using Capistrano to AWS Auto Scaling groups but both
9
+ required you to do so in a non-straightforward manner by putting your Auto Scaling group in its own
10
+ security group or by providing a unique tag for your Auto Scaling group. This plugin simply takes the
11
+ name of the Auto Scaling group and uses that to find the Auto Scaling instances that it should deploy to. It will
12
+ work with straight up hand created Auto Scaling groups (exact match of the AS group name) or with
13
+ Cloud Formation created Auto Scaling groups (looking for the name in the Cloud Formation format).
14
+
15
+ ## Installation
16
+
17
+ ### Set the Amazon AWS Credentials
18
+
19
+ In order for the plugin to list out the hostnames of your AWS Auto Scaling instances, it
20
+ will need access to the Amazon AWS API. It is recommended to use IAM to create credentials
21
+ with limited capabilities for this type of purpose. Specify the following in your
22
+ Capistrano configuration:
23
+
24
+ ```ruby
25
+ set :aws_access_key_id, '...'
26
+ set :aws_secret_access_key, '...'
27
+ ```
28
+
29
+ ### Get the gem
30
+
31
+ The plugin is distributed as a Ruby gem.
32
+
33
+ **Ruby Gems**
34
+
35
+ ```bash
36
+ gem install capistrano-asgroup
37
+ ```
38
+
39
+ **Bundler**
40
+
41
+ Using [bundler](http://gembundler.com/)?
42
+
43
+ ```bash
44
+ gem install bundler
45
+ ```
46
+
47
+ Then add the following to your Gemfile:
48
+
49
+ ```ruby
50
+ source 'http://rubygems.org'
51
+ gem 'capistrano-asgroup'
52
+ ```
53
+
54
+ Install the gems in your manifest using:
55
+
56
+ ```bash
57
+ bundle install
58
+ ```
59
+
60
+ ## Usage
61
+
62
+ ### Configure Capistrano
63
+
64
+ Instead of manually defining the hostnames to deploy to like this:
65
+
66
+ ```ruby
67
+ role :web, 'mysever1.example.com','myserver2.example.com'
68
+ ```
69
+
70
+ Simple do this where <my-autoscale-group-name> is the name of an autoscale group:
71
+
72
+ ```ruby
73
+ asgroupname '<my-autoscale-group-name>', :web
74
+ ```
75
+
76
+ So instead of:
77
+
78
+ ```ruby
79
+ task :production do
80
+ role :web, 'mysever1.example.com','myserver2.example.com'
81
+ logger.info 'Deploying to the PRODUCTION environment!'
82
+ end
83
+ ```
84
+
85
+ You would do:
86
+
87
+ ```ruby
88
+ require 'capistrano/asgroup'
89
+
90
+ task :production do
91
+ asgroupname 'production-github-web', :web
92
+ logger.info 'Deploying to the PRODUCTION environment!'
93
+ end
94
+ ```
95
+
96
+ ## License
97
+
98
+ capistrano-asgroup is copyright 2013 by [Thomas Verbiscer](http://tom.verbiscer.com/), released under the MIT License (see LICENSE for details).
99
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'capistrano-asgroup'
6
+ s.version = '0.0.1'
7
+ s.authors = ['Thomas Verbiscer']
8
+ s.date = '2013-01-17'
9
+ s.email = ['asgroup@verbiscer.com']
10
+ s.homepage = 'https://github.com/tverbiscer/capistrano-asgroup'
11
+ s.summary = 'A Capistrano plugin aimed at easing the pain of deploying to AWS Auto Scale instances.'
12
+ s.description = 'capistrano-asgroup is a Capistrano plugin designed to simplify the task of deploying to infrastructure hosted on Amazon AWS, in particular, within Auto Scaling Groups. It was completely inspired by the capistrano-ec2group and capistrano-ec2tag plugins, to which all credit is due.'
13
+
14
+ s.rubyforge_project = 'capistrano-asgroup'
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ['lib']
20
+
21
+ s.add_dependency 'capistrano', '>=2.1.0'
22
+ s.add_dependency 'right_aws'
23
+ end
@@ -0,0 +1 @@
1
+ require 'capistrano/asgroup'
@@ -0,0 +1,46 @@
1
+ require 'right_aws'
2
+
3
+ unless Capistrano::Configuration.respond_to?(:instance)
4
+ abort 'capistrano/asgroup requires Capistrano >= 2'
5
+ end
6
+
7
+ module Capistrano
8
+ class Configuration
9
+ module Asgroup
10
+
11
+ def asgroupname(which, *args)
12
+
13
+ # Get Auto Scaling API obj
14
+ @as_api ||= RightAws::AsInterface.new(fetch(:aws_access_key_id), fetch(:aws_secret_access_key), {})
15
+ # Get EC2 API obj
16
+ @ec2_api ||= RightAws::Ec2.new(fetch(:aws_access_key_id), fetch(:aws_secret_access_key), {})
17
+
18
+ # Get descriptions of all the Auto Scaling groups
19
+ @autoScaleDesc = @as_api.describe_auto_scaling_groups
20
+ # Get descriptions of all the EC2 instances
21
+ @ec2DescInst = @ec2_api.describe_instances
22
+
23
+ # Find the right Auto Scaling group
24
+ @autoScaleDesc.each do |asGroup|
25
+ # Look for an exact name match or Cloud Formation style match (<cloud_formation_script>-<as_name>-<generated_id>)
26
+ if asGroup[:auto_scaling_group_name] == which or asGroup[:auto_scaling_group_name].scan("-#{which}-").length > 0
27
+ # For each instance in the Auto Scale group
28
+ asGroup[:instances].each do |asInstance|
29
+ # Get description of all instances so that we can find the DNS names based on instance ID
30
+ @ec2DescInst.delete_if{|i| i[:aws_state] != "running"}.each do |instance|
31
+ # Match the instance IDs
32
+ if instance[:aws_instance_id] == asInstance[:instance_id]
33
+ puts "AS Instance ID: #{asInstance[:instance_id]} DNS: #{instance[:dns_name]}"
34
+ server(instance[:dns_name], *args)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ include Asgroup
44
+ end
45
+ end
46
+
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-asgroup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thomas Verbiscer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.1.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: right_aws
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: capistrano-asgroup is a Capistrano plugin designed to simplify the task
47
+ of deploying to infrastructure hosted on Amazon AWS, in particular, within Auto
48
+ Scaling Groups. It was completely inspired by the capistrano-ec2group and capistrano-ec2tag
49
+ plugins, to which all credit is due.
50
+ email:
51
+ - asgroup@verbiscer.com
52
+ executables: []
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.markdown
59
+ - Rakefile
60
+ - capistrano-asgroup.gemspec
61
+ - lib/capistrano-asgroup.rb
62
+ - lib/capistrano/asgroup.rb
63
+ homepage: https://github.com/tverbiscer/capistrano-asgroup
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project: capistrano-asgroup
83
+ rubygems_version: 1.8.24
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: A Capistrano plugin aimed at easing the pain of deploying to AWS Auto Scale
87
+ instances.
88
+ test_files: []