ec2-i2cssh 0.6.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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/bin/cluster +89 -0
- data/ec2-i2cssh.gemspec +25 -0
- data/lib/ec2/clusterssh/version.rb +5 -0
- data/lib/ec2/clusterssh.rb +7 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d919d3e54c37a3d2bd86811f06745bd08b320808
|
4
|
+
data.tar.gz: 381278c2ad69f908b9e48e767a1d6f4f7670db2a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1bec4cc673c261aa7d8fa3f2a4b66510708edfa11ac96e61cb95d0251b9d4d73a13241f9aee2faf991cce6198e9cf69c822827bd127ef35c5f95ac0682ac5459
|
7
|
+
data.tar.gz: 07135b7563eaef6a514769614ab0e77ee1127d9b4b41905d351be65d1cc1970ed233918e45ba27cd1b851d7faa0c613f8cf34a7ce5c806eeec3de2b6c16d15c6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Glenn Poston
|
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,51 @@
|
|
1
|
+
# Ec2::Clusterssh
|
2
|
+
|
3
|
+
Forked from gposton/ec2-clusterssh -- uses i2cssh instead of csshX on macos
|
4
|
+
|
5
|
+
Use instance tags to launch a ClusterSSH session to multiple EC2 instances.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install ec2-i2cssh
|
10
|
+
|
11
|
+
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
|
12
|
+
|
13
|
+
> clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
|
14
|
+
|
15
|
+
## Prerequisites
|
16
|
+
|
17
|
+
- [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/))
|
18
|
+
- Set up your AWS credentials (note that these values can be also passed in
|
19
|
+
as command line options)
|
20
|
+
|
21
|
+
> export AWS_ACCESS_KEY_ID='...'
|
22
|
+
|
23
|
+
> export AWS_SECRET_ACCESS_KEY='...'
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
$cluster -h
|
28
|
+
Usage: cluster [-t TAGS] [-l USER] [-k KEY -s SECRET] [-r region]
|
29
|
+
-l, --login [USER] Log in with this user
|
30
|
+
-t, --tags [TAGS] a 'space' sparated key value pair of tags and values (i.e. -t 'role=web,database environment=dev')
|
31
|
+
-r, --region [REGION] AWS region
|
32
|
+
-s, --screen [SCREEN] What screen to use for clustering windows (form multiple displays)
|
33
|
+
-p, --use-public-ip Use public IP (default false)
|
34
|
+
|
35
|
+
|
36
|
+
$cluster -t Name=web,database #Connects to all web and database servers
|
37
|
+
$cluster -t 'role=web,database environment=dev' #Connects to all web and database servers in the dev environment
|
38
|
+
|
39
|
+
## Notes
|
40
|
+
|
41
|
+
If you use a bastion jumphost, you'll want to configure your ssh config
|
42
|
+
file to route the relavant IP ranges through your bastion. (i.e.
|
43
|
+
192.168.*)
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/cluster
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'aws-sdk'
|
6
|
+
|
7
|
+
options = {
|
8
|
+
'use_public_ip' => false,
|
9
|
+
'region' => 'us-west-2'
|
10
|
+
}
|
11
|
+
|
12
|
+
OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: cluster [-t TAGS] [-l USER] [-k KEY -s SECRET] [-r region]"
|
14
|
+
|
15
|
+
opts.on("-l", "--login [USER]", "Log in with this user") do |opt|
|
16
|
+
options['user'] = opt
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("-t", "--tags [TAGS]", Array, "a 'comma' sparated key value pair of tags and values (i.e. role=web|database,environment=dev)") do |opt|
|
20
|
+
options['tags'] = opt
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("-r", "--region [REGION]", "AWS region") do |opt|
|
24
|
+
options['region'] = opt
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on("-s", "--screen [SCREEN]", "What screen to use for clustering windows (form multiple displays)") do |opt|
|
28
|
+
options['screen'] = opt
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("-p", "--use-public-ip", "Use public IP (default #{options['use_public_ip']})") do
|
32
|
+
options['use_public_ip'] = true
|
33
|
+
end
|
34
|
+
|
35
|
+
end.parse!
|
36
|
+
|
37
|
+
Aws.config.update({:region => options['region']})
|
38
|
+
$ec2 = Aws::EC2::Client.new
|
39
|
+
|
40
|
+
def get_ip(instance, options)
|
41
|
+
if options['use_public_ip']
|
42
|
+
return instance.public_ip_address
|
43
|
+
else
|
44
|
+
return instance.private_ip_address
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_instances_by_tag (tag_key,tag_values,options)
|
49
|
+
instances = []
|
50
|
+
response = $ec2.describe_instances(filters: [{:name => "tag:#{tag_key}", :values => tag_values},{:name => "instance-state-name", :values => ['running']}])
|
51
|
+
if response.reservations[0].nil?
|
52
|
+
puts "No running instances in #{options['region']} had a tag named '#{tag_key}' with values '#{tag_values}'"
|
53
|
+
else
|
54
|
+
response.reservations.each do |reservation|
|
55
|
+
reservation.instances.each do |instance|
|
56
|
+
instances << get_ip(instance, options)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
return instances
|
61
|
+
end
|
62
|
+
|
63
|
+
matched_instances = []
|
64
|
+
# filter instances based on tags
|
65
|
+
options['tags'].each do |tag|
|
66
|
+
tag = tag.split('=')
|
67
|
+
key = tag[0]
|
68
|
+
values = tag[1].split('|')
|
69
|
+
if matched_instances.empty?
|
70
|
+
matched_instances = get_instances_by_tag(key,values,options)
|
71
|
+
end
|
72
|
+
matched_instances = matched_instances & get_instances_by_tag(key,values,options)
|
73
|
+
end
|
74
|
+
|
75
|
+
if matched_instances.length == 0
|
76
|
+
puts "No instnaces matched filter: #{options['tags']}"
|
77
|
+
exit 1
|
78
|
+
end
|
79
|
+
|
80
|
+
cssh = (/darwin/ =~ RUBY_PLATFORM) ? 'i2cssh' : 'cssh'
|
81
|
+
|
82
|
+
cmd = "#{cssh}"
|
83
|
+
cmd = cmd + " -l #{options['user']}" unless options['user'].nil?
|
84
|
+
cmd = cmd + " -screen #{options['screen']}" unless options['screen'].nil?
|
85
|
+
cmd = cmd + " #{matched_instances.join ' '}"
|
86
|
+
|
87
|
+
puts "Connecting to #{matched_instances.length} instances"
|
88
|
+
puts cmd
|
89
|
+
exec cmd
|
data/ec2-i2cssh.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ec2/clusterssh/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ec2-i2cssh"
|
8
|
+
spec.version = Ec2::Clusterssh::VERSION
|
9
|
+
spec.authors = ["Ber Zoidberg"]
|
10
|
+
spec.email = ["ber.zoidberg@gmail.com"]
|
11
|
+
spec.description = %q{Use instance tags to launch a I2CSSH session to multiple EC2 instances.}
|
12
|
+
spec.summary = %q{Use instance tags to launch a I2CSSH session to multiple EC2 instances.}
|
13
|
+
spec.homepage = "https://github.com/zoidbb/ec2-i2cssh"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency 'aws-sdk'
|
24
|
+
spec.add_dependency 'i2cssh'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ec2-i2cssh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ber Zoidberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aws-sdk
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: i2cssh
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Use instance tags to launch a I2CSSH session to multiple EC2 instances.
|
70
|
+
email:
|
71
|
+
- ber.zoidberg@gmail.com
|
72
|
+
executables:
|
73
|
+
- cluster
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/cluster
|
83
|
+
- ec2-i2cssh.gemspec
|
84
|
+
- lib/ec2/clusterssh.rb
|
85
|
+
- lib/ec2/clusterssh/version.rb
|
86
|
+
homepage: https://github.com/zoidbb/ec2-i2cssh
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.5.2.3
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Use instance tags to launch a I2CSSH session to multiple EC2 instances.
|
110
|
+
test_files: []
|