ec2cssh 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 150662767347f26dd4f394530531e5ac6bdad7bb
4
+ data.tar.gz: 9dcd3da5fc43eba9ca44f324c1c9ac99d14528f8
5
+ SHA512:
6
+ metadata.gz: 186d45eed94c06dbaad627a27c20a0a0f3f66412e2bcf908ef7f2c696115eb3f76e639e781365875556aa19d833b745bc6b0e7c149ca1de486324dbefc76e1a9
7
+ data.tar.gz: 31edca3c11dc3f328675f4681f870781377e5483a4c4541059688dc94ceea56331182ad1b1f16f514a581e5f953c4bd3fe0ae4fe8e670ab5bda801ddb1e46641
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+ /vendor
15
+ Gemfile.lock
16
+
17
+ # YARD artifacts
18
+ .yardoc
19
+ _yardoc
20
+ doc/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ec2cssh.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 bash0C7
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,88 @@
1
+ # ec2cssh
2
+
3
+ Cluster SSH connect to pattern mached hosts (Connected by cssh) (Hosts in ssh config written by ec2ssh)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ec2cssh'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ec2cssh
18
+
19
+ ## Prepair
20
+
21
+ - install ec2ssh & run ec2ssh init
22
+ - install cssh
23
+
24
+ ## Usage
25
+
26
+ ex)
27
+
28
+ ````sh
29
+ $ ec2cssh connect '\S+-production'
30
+ ````
31
+
32
+ run 'ec2ssh update' command and grep Host name by Server name pattern parameter.
33
+ finaly connect hosts using 'cssh' command
34
+
35
+
36
+ ### Parameters
37
+
38
+ #### 1. Server name pattern (required)
39
+
40
+ ex)
41
+
42
+ 'ec2ssh update' result
43
+ ````
44
+ ### EC2SSH BEGIN ###
45
+ # Generated by ec2ssh http://github.com/mirakui/ec2ssh
46
+ # DO NOT edit this block!
47
+ # Updated Sun Dec 05 00:00:14 +0900 2010
48
+
49
+ # section: default
50
+ Host app-server-1.us-west-1
51
+ HostName ec2-xxx-xxx-xxx-xxx.us-west-1.compute.amazonaws.com
52
+ Host app-server-2.us-west-1
53
+ HostName ec2-xxx-xxx-xxx-xxx.us-west-1.compute.amazonaws.com
54
+ Host db-server-1.ap-southeast-1
55
+ HostName ec2-xxx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com
56
+ ### EC2SSH END ###
57
+ ````
58
+
59
+ Server name pattern: 'app-server.*' => connect to app-server-1.us-west-1 and app-server-2.us-west-1
60
+
61
+ ### Options(optional)
62
+
63
+ #### 1. --ec2ssh_update : ec2ssh update command
64
+
65
+ ex) --ec2ssh_update 'ec2ssh update --aws-key my_key1'
66
+
67
+ default 'ec2ssh update'
68
+
69
+ #### 2. --cssh : cssh command
70
+
71
+ ex) --cssh 'cssh --config /path/to/configfile'
72
+ ex) --cssh 'csshx'
73
+
74
+ default 'cssh'
75
+
76
+ #### 3. --port
77
+
78
+ SSH Port No
79
+
80
+ ex) --port '9999'
81
+
82
+ ## Contributing
83
+
84
+ 1. Fork it
85
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
86
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
87
+ 4. Push to the branch (`git push origin my-new-feature`)
88
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/ec2cssh ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path('../../lib', __FILE__)
3
+ require 'ec2cssh/cli'
4
+ Ec2cssh::CLI.start
data/ec2cssh.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ec2cssh/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ec2cssh"
8
+ spec.version = Ec2cssh::VERSION
9
+ spec.authors = ["bash0C7"]
10
+ spec.email = ["koshiba+github@4038nullpointer.com"]
11
+ spec.description = 'Cluster SSH connect to pattern mached hosts (Connected by cssh) (Hosts in ssh config written by ec2ssh)'
12
+ spec.summary = 'Cluster SSH connect to pattern mached hosts (Connected by cssh) (Hosts in ssh config written by ec2ssh)'
13
+ spec.homepage = "https://github.com/bash0C7/ec2cssh"
14
+ spec.license = "Ruby's"
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_dependency 'thor'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ end
data/lib/ec2cssh.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "ec2cssh/version"
2
+
3
+ module Ec2cssh
4
+ end
@@ -0,0 +1,31 @@
1
+ require 'thor'
2
+
3
+ module Ec2cssh
4
+ class CLI < Thor
5
+ desc "connect", "connect"
6
+ method_option :ec2ssh_update, :banner => 'ec2ssh_update_command', :default => 'ec2ssh update'
7
+ method_option :cssh, :banner => 'cssh_command', :default => 'cssh'
8
+ method_option :port, :banner => 'ssh port', :default => nil
9
+
10
+ def connect servers_name_pattern
11
+
12
+ ec2ssh_update_command = options.ec2ssh_update
13
+ cssh_command = options.cssh
14
+ port = options.port.nil? ? '' : ':' + options.port
15
+ ec2ssh_update_result = `#{ec2ssh_update_command}`
16
+ puts ec2ssh_update_command
17
+ puts ec2ssh_update_result
18
+ puts
19
+
20
+ servers = ec2ssh_update_result.scan(/^Host\s(#{servers_name_pattern})/).map{|matches| "#{matches.first}#{port}" }.join(' ')
21
+
22
+ puts servers_name_pattern
23
+ puts servers
24
+ puts
25
+
26
+ puts "#{cssh_command} #{servers}"
27
+ puts `#{cssh_command} #{servers}`
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ module Ec2cssh
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ec2cssh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - bash0C7
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Cluster SSH connect to pattern mached hosts (Connected by cssh) (Hosts
70
+ in ssh config written by ec2ssh)
71
+ email:
72
+ - koshiba+github@4038nullpointer.com
73
+ executables:
74
+ - ec2cssh
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - .gitignore
79
+ - .rspec
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/ec2cssh
86
+ - ec2cssh.gemspec
87
+ - lib/ec2cssh.rb
88
+ - lib/ec2cssh/cli.rb
89
+ - lib/ec2cssh/version.rb
90
+ - spec/spec_helper.rb
91
+ homepage: https://github.com/bash0C7/ec2cssh
92
+ licenses:
93
+ - Ruby's
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.0.0
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Cluster SSH connect to pattern mached hosts (Connected by cssh) (Hosts in
115
+ ssh config written by ec2ssh)
116
+ test_files:
117
+ - spec/spec_helper.rb