ec2-clusterssh 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -3
- data/bin/cluster +22 -24
- data/ec2-clusterssh.gemspec +1 -0
- data/lib/ec2/clusterssh/version.rb +1 -1
- metadata +20 -4
data/README.md
CHANGED
@@ -9,6 +9,15 @@ Use instance tags to launch a ClusterSSH session to multiple EC2 instances.
|
|
9
9
|
## Prerequisites
|
10
10
|
|
11
11
|
- [ClusterSSH](http://sourceforge.net/apps/mediawiki/clusterssh/index.php?title=Main_Page)
|
12
|
+
- Set up your AWS credentials (note that these values can be also passed in
|
13
|
+
as command line options)
|
14
|
+
|
15
|
+
> export AWS_ACCESS_KEY_ID='...'
|
16
|
+
|
17
|
+
> export AWS_SECRET_ACCESS_KEY='...'
|
18
|
+
|
19
|
+
> export AWS_REGION='us-west-2'
|
20
|
+
|
12
21
|
- Edit /etc/csshrc to add the path to your identity file (rsa key).
|
13
22
|
|
14
23
|
> ssh_args = "-i path/to/identity/file"
|
@@ -16,10 +25,13 @@ Use instance tags to launch a ClusterSSH session to multiple EC2 instances.
|
|
16
25
|
## Usage
|
17
26
|
|
18
27
|
$cluster -h
|
19
|
-
Usage: cluster [-t TAG] -v VALUES
|
28
|
+
Usage: cluster [-t TAG] [-l USER] [-k KEY -s SECRET] [-r region] -v VALUES
|
29
|
+
-l, --login [USER] Log in with this user (default: ec2-user)
|
20
30
|
-t, --tag [TAG] TAG to filter on (default: role)
|
21
|
-
-v, --values [VALUES] a comma separated (no spaces) of values to match against (i.e. web,database)
|
22
|
-
|
31
|
+
-v, --values [VALUES] a comma separated (no spaces) list of values to match against (i.e. web,database)
|
32
|
+
-k, --access-key [KEY] AWS access key
|
33
|
+
-s, --secret-key [SECRET] AWS secret key
|
34
|
+
-r, --region [REGION] AWS region
|
23
35
|
|
24
36
|
$cluster -l ec2-user -t Name -v web,database
|
25
37
|
|
data/bin/cluster
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'aws-sdk'
|
4
6
|
|
5
7
|
options = {'tag' => 'role', 'user' => 'ec2-user'}
|
6
8
|
OptionParser.new do |opts|
|
7
|
-
opts.banner = "Usage: cluster [-t TAG -l USER] -v VALUES"
|
9
|
+
opts.banner = "Usage: cluster [-t TAG] [-l USER] [-k KEY -s SECRET] [-r region] -v VALUES"
|
8
10
|
|
9
11
|
opts.on("-l", "--login [USER]", "Log in with this user (default: #{options['user']}") do |opt|
|
10
12
|
options['user'] = opt
|
@@ -17,35 +19,31 @@ OptionParser.new do |opts|
|
|
17
19
|
opts.on("-v", "--values [VALUES]", Array, "a comma separated (no spaces) list of values to match against (i.e. web,database)") do |opt|
|
18
20
|
options['values'] = opt
|
19
21
|
end
|
20
|
-
end.parse!
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
output = %x{ec2-describe-instances}
|
26
|
-
output.split(/\n/).each do |line|
|
27
|
-
words = line.split(/\s/)
|
28
|
-
if words[0] == 'INSTANCE'
|
29
|
-
instance_id = words[1]
|
30
|
-
public_dns = words[3]
|
31
|
-
instances[instance_id] = public_dns
|
32
|
-
elsif words[0] == 'TAG'
|
33
|
-
instance_id = words[2]
|
34
|
-
tag = words[3]
|
35
|
-
value = words[4]
|
36
|
-
tags[tag] = {} if tags[tag].nil?
|
37
|
-
tags[tag][value] = [] if tags[tag][value].nil?
|
38
|
-
tags[tag][value] << instance_id
|
23
|
+
opts.on("-k", "--access-key [KEY]", "AWS access key") do |opt|
|
24
|
+
options['aws_access_key'] = opt
|
39
25
|
end
|
40
|
-
end
|
41
26
|
|
42
|
-
|
43
|
-
options['
|
44
|
-
tags[options['tag']][value].each do |instance_id|
|
45
|
-
dns << instances[instance_id]
|
27
|
+
opts.on("-s", "--secret-key [SECRET]", "AWS secret key") do |opt|
|
28
|
+
options['aws_secret_key'] = opt
|
46
29
|
end
|
30
|
+
|
31
|
+
opts.on("-r", "--region [REGION]", "AWS region") do |opt|
|
32
|
+
options['region'] = opt
|
33
|
+
end
|
34
|
+
end.parse!
|
35
|
+
|
36
|
+
if !options['aws_secret_key'].nil? && !options['aws_access_key'].nil?
|
37
|
+
AWS.config(access_key_id: options['aws_access_key'], secret_access_key: options['aws_secret_key'])
|
38
|
+
end
|
39
|
+
|
40
|
+
if !options['region'].nil?
|
41
|
+
AWS.config(region: options['region'])
|
47
42
|
end
|
48
43
|
|
44
|
+
ec2 = AWS.ec2
|
45
|
+
dns = ec2.instances.tagged(options['tag']).tagged_values(options['values']).map{|instance| instance.dns_name}
|
46
|
+
|
49
47
|
cssh = (/darwin/ =~ RUBY_PLATFORM) ? 'csshX' : 'cssh'
|
50
48
|
|
51
49
|
exec "#{cssh} -l #{options['user']} #{dns.join ' '}"
|
data/ec2-clusterssh.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ec2-clusterssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: aws-sdk
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
description: Use instance tags to launch a ClusterSSH session to multiple EC2 instances.
|
47
63
|
email:
|
48
64
|
- gposton1040@gmail.com
|
@@ -75,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
91
|
version: '0'
|
76
92
|
segments:
|
77
93
|
- 0
|
78
|
-
hash:
|
94
|
+
hash: -1450336275784820976
|
79
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
96
|
none: false
|
81
97
|
requirements:
|
@@ -84,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
100
|
version: '0'
|
85
101
|
segments:
|
86
102
|
- 0
|
87
|
-
hash:
|
103
|
+
hash: -1450336275784820976
|
88
104
|
requirements: []
|
89
105
|
rubyforge_project:
|
90
106
|
rubygems_version: 1.8.25
|