cap-elb 0.0.1 → 0.0.2

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/README.markdown ADDED
@@ -0,0 +1,14 @@
1
+ cap-elb
2
+ =================================================
3
+
4
+ Capistrano plugin or deploying to Amazon EC2 instances behind ELBs
5
+
6
+
7
+ Introduction
8
+ ============
9
+
10
+ This capistrano plugin
11
+
12
+ Installation
13
+ ============
14
+
data/Rakefile CHANGED
@@ -1 +1,2 @@
1
1
  require 'bundler/gem_tasks'
2
+
data/cap-elb.gemspec CHANGED
@@ -3,18 +3,23 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
  require "cap-elb/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "cap-elb"
7
- s.version = Cap::Elb::VERSION
8
- s.authors = ["Dan Miley"]
9
- s.email = ["dan.miley@gmail.com"]
10
- s.homepage = ""
11
- s.summary = %q{Capistrano can perform tasks on Amazon ELB instances}
12
- s.description = %q{Capistrano can perform tasks on Amazon ELB instances}
6
+ s.name = "cap-elb"
7
+ s.version = Cap::Elb::VERSION
8
+ s.authors = ["Dan Miley"]
9
+ s.email = ["dan.miley@gmail.com"]
10
+ s.homepage = "http://github.com/danmiley/cap-elb"
11
+ s.summary = %q{Capistrano can perform tasks on Amazon ELB instances}
12
+ s.description = %q{Capistrano can perform tasks on Amazon ELB instances; various arguments to allow instance tags to determine whether task should be applied on the given tag}
13
+
14
+ s.rubyforge_project = "cap-elb"
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 "right_aws", "2.1.0"
22
+ s.add_development_dependency "rspec", "~> 2.6"
13
23
 
14
- s.rubyforge_project = "cap-elb"
15
24
 
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
25
  end
@@ -1,5 +1,5 @@
1
1
  module Cap
2
2
  module Elb
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/lib/cap-elb.rb CHANGED
@@ -1,7 +1,58 @@
1
1
  require "cap-elb/version"
2
+ require 'right_aws'
2
3
 
3
- module Cap
4
- module Elb
5
- # Your code goes here...
4
+ unless Capistrano::Configuration.respond_to?(:instance)
5
+ abort "capistrano/elb requires Capistrano 2"
6
+ end
7
+
8
+ module Capistrano
9
+ class Configuration
10
+ module LoadBalancers
11
+ # Associate a group of EC2 instances behind a load balancer with a role. In order to use this, you
12
+ # must use the Load Balancer feature in Amazon EC2 to group your servers
13
+ # by role.
14
+ #
15
+ # First, specify the load balancer name, then the roles and params:
16
+ #
17
+ # group :webserver, :web
18
+ # group :app_myappname, :app
19
+ # group "MySQL Servers", :db, :port => 22000
20
+ def loadbalancer (which, *args)
21
+
22
+ # list of all the instances assoc'ed with this account
23
+ @ec2_api ||= RightAws::Ec2.new(fetch(:aws_access_key_id), fetch(:aws_secret_access_key), fetch(:aws_params, {}))
24
+
25
+ # fetch a raw list all the load balancers
26
+ @elb_api ||= RightAws::ElbInterface.new(fetch(:aws_access_key_id), fetch(:aws_secret_access_key))
27
+ # only get the named load balancer
28
+ named_elb_instance = @elb_api.describe_load_balancers.delete_if{ |i| i[:load_balancer_name] != which.to_s }
29
+
30
+ print "named elb instnaces" + named_elb_instance.to_s
31
+
32
+ elb_ec2_instances = named_elb_instance[0][:instances] rescue {}
33
+
34
+ # print "named elb ec2 instnaces" + elb_ec2_instances.to_s
35
+ print "here are our ARGSXXX" + args[1].to_s
36
+
37
+ # this is the target state we extract from param, unless that param is present in the instance, we dont update
38
+ run_state = args[1][:state] rescue 'run'
39
+
40
+ #now, we have a hash of either zero or one ELBs, assuming unique names
41
+ @ec2_api.describe_instances.delete_if{ |i| i[:aws_state] != "running"}.each do |instance|
42
+ # unless this ec2 instance is in the LB, nuke it
43
+ if elb_ec2_instances.include?(instance[:aws_instance_id]) && instance[:tags]['state'] == run_state
44
+ server(instance[:dns_name], *args)
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ include LoadBalancers
6
51
  end
7
52
  end
53
+
54
+ # module Cap
55
+ # module Elb
56
+ # # Your code goes here...
57
+ # end
58
+ # end
data/spec/.gemtest ADDED
File without changes
data/spec/elb_test.rb ADDED
File without changes
metadata CHANGED
@@ -1,73 +1,79 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cap-elb
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Dan Miley
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-10-25 00:00:00 -07:00
19
- default_executable:
20
- dependencies: []
21
-
22
- description: Capistrano can perform tasks on Amazon ELB instances
23
- email:
12
+ date: 2011-10-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: right_aws
16
+ requirement: &2152611080 !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: *2152611080
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &2152610560 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '2.6'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2152610560
36
+ description: Capistrano can perform tasks on Amazon ELB instances; various arguments
37
+ to allow instance tags to determine whether task should be applied on the given
38
+ tag
39
+ email:
24
40
  - dan.miley@gmail.com
25
41
  executables: []
26
-
27
42
  extensions: []
28
-
29
43
  extra_rdoc_files: []
30
-
31
- files:
44
+ files:
32
45
  - .gitignore
33
46
  - Gemfile
47
+ - README.markdown
34
48
  - Rakefile
35
49
  - cap-elb.gemspec
36
50
  - lib/cap-elb.rb
37
51
  - lib/cap-elb/version.rb
38
- has_rdoc: true
39
- homepage: ""
52
+ - spec/.gemtest
53
+ - spec/elb_test.rb
54
+ homepage: http://github.com/danmiley/cap-elb
40
55
  licenses: []
41
-
42
56
  post_install_message:
43
57
  rdoc_options: []
44
-
45
- require_paths:
58
+ require_paths:
46
59
  - lib
47
- required_ruby_version: !ruby/object:Gem::Requirement
60
+ required_ruby_version: !ruby/object:Gem::Requirement
48
61
  none: false
49
- requirements:
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- hash: 3
53
- segments:
54
- - 0
55
- version: "0"
56
- required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
67
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
- version: "0"
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
65
72
  requirements: []
66
-
67
73
  rubyforge_project: cap-elb
68
- rubygems_version: 1.6.0
74
+ rubygems_version: 1.8.5
69
75
  signing_key:
70
76
  specification_version: 3
71
77
  summary: Capistrano can perform tasks on Amazon ELB instances
72
- test_files: []
73
-
78
+ test_files:
79
+ - spec/elb_test.rb