ec2-clusterssh 0.2.0 → 0.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.
- data/README.md +13 -7
- data/bin/cluster +15 -11
- data/lib/ec2/clusterssh/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -5,10 +5,14 @@ Use instance tags to launch a ClusterSSH session to multiple EC2 instances.
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
$ gem install ec2-clusterssh
|
8
|
+
|
9
|
+
Note: Mac users with the latest version of XCode may run into a compilation error installing the json gem dependency. If you see the following error during the gem installation, see this [page](https://langui.sh/2014/03/10/wunused-command-line-argument-hard-error-in-future-is-a-harsh-mistress/) for a workaround
|
10
|
+
|
11
|
+
> clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
|
8
12
|
|
9
13
|
## Prerequisites
|
10
14
|
|
11
|
-
- [ClusterSSH](http://sourceforge.net/apps/mediawiki/clusterssh/index.php?title=Main_Page)
|
15
|
+
- [ClusterSSH](http://sourceforge.net/apps/mediawiki/clusterssh/index.php?title=Main_Page) (To install csshx on mac use this [page](https://code.google.com/p/csshx/))
|
12
16
|
- Set up your AWS credentials (note that these values can be also passed in
|
13
17
|
as command line options)
|
14
18
|
|
@@ -19,21 +23,23 @@ Use instance tags to launch a ClusterSSH session to multiple EC2 instances.
|
|
19
23
|
> export AWS_REGION='us-west-2'
|
20
24
|
|
21
25
|
- Edit /etc/csshrc to add the path to your identity file (rsa key).
|
26
|
+
NOTE: Some linux users have reported problems using /etc/csshrc, but have had success using ~/.csshrc.
|
22
27
|
|
23
|
-
> ssh_args =
|
28
|
+
> ssh_args = -i path/to/identity/file
|
24
29
|
|
25
30
|
## Usage
|
26
31
|
|
27
32
|
$cluster -h
|
28
|
-
Usage: cluster [-t
|
29
|
-
-l, --login [USER] Log in with this user (default: ec2-user
|
30
|
-
-t, --
|
31
|
-
-v, --values [VALUES] a comma separated (no spaces) list of values to match against (i.e. web,database)
|
33
|
+
Usage: cluster [-t TAGS] [-l USER] [-k KEY -s SECRET] [-r region]
|
34
|
+
-l, --login [USER] Log in with this user (default: ec2-user
|
35
|
+
-t, --tags [TAGS] a 'space' sparated key value pair of tags and values (i.e. role=web,database environment=dev)
|
32
36
|
-k, --access-key [KEY] AWS access key
|
33
37
|
-s, --secret-key [SECRET] AWS secret key
|
34
38
|
-r, --region [REGION] AWS region
|
39
|
+
-p, --use-private-ip Use private IP (default false)
|
35
40
|
|
36
|
-
$cluster -l ec2-user -t Name
|
41
|
+
$cluster -l ec2-user -t Name=web,database #Connects to all web and database servers
|
42
|
+
$cluster -l ec2-user -t role=web,database environment=dev #Connects to all web and database servers in the dev environment
|
37
43
|
|
38
44
|
## Contributing
|
39
45
|
|
data/bin/cluster
CHANGED
@@ -4,20 +4,16 @@ require 'optparse'
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'aws-sdk'
|
6
6
|
|
7
|
-
options = {'
|
7
|
+
options = {'user' => 'ec2-user', 'use_private_ip' => false}
|
8
8
|
OptionParser.new do |opts|
|
9
|
-
opts.banner = "Usage: cluster [-t
|
9
|
+
opts.banner = "Usage: cluster [-t TAGS] [-l USER] [-k KEY -s SECRET] [-r region]"
|
10
10
|
|
11
11
|
opts.on("-l", "--login [USER]", "Log in with this user (default: #{options['user']}") do |opt|
|
12
12
|
options['user'] = opt
|
13
13
|
end
|
14
14
|
|
15
|
-
opts.on("-t", "--
|
16
|
-
options['
|
17
|
-
end
|
18
|
-
|
19
|
-
opts.on("-v", "--values [VALUES]", Array, "a comma separated (no spaces) list of values to match against (i.e. web,database)") do |opt|
|
20
|
-
options['values'] = opt
|
15
|
+
opts.on("-t", "--tags [TAGS]", Array, "a 'space' sparated key value pair of tags and values (i.e. role=web,database environment=dev)") do |opt|
|
16
|
+
options['tags'] = opt
|
21
17
|
end
|
22
18
|
|
23
19
|
opts.on("-k", "--access-key [KEY]", "AWS access key") do |opt|
|
@@ -46,14 +42,22 @@ if !options['region'].nil?
|
|
46
42
|
end
|
47
43
|
|
48
44
|
ec2 = AWS.ec2
|
45
|
+
|
46
|
+
# filter instances based on tags
|
47
|
+
instances = ec2.instances
|
48
|
+
options['tags'].each do |tag|
|
49
|
+
tag = tag.split('=')
|
50
|
+
instances = instances.tagged(tag[0]).tagged_values(tag[1])
|
51
|
+
end
|
52
|
+
|
53
|
+
# get dns entries for cssh
|
49
54
|
dns = nil
|
50
55
|
if options['use_private_ip']
|
51
|
-
dns =
|
56
|
+
dns = instances.map{|instance| instance.private_ip_address}
|
52
57
|
else
|
53
|
-
dns =
|
58
|
+
dns = instances.map{|instance| instance.dns_name}
|
54
59
|
end
|
55
60
|
|
56
|
-
|
57
61
|
cssh = (/darwin/ =~ RUBY_PLATFORM) ? 'csshX' : 'cssh'
|
58
62
|
|
59
63
|
exec "#{cssh} -l #{options['user']} #{dns.join ' '}"
|
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.
|
4
|
+
version: 0.3.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: 2014-
|
12
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|