owssh 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/owssh +83 -0
  3. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 526e06eb0fe64bbd9019ab6b5146497035c07d2c
4
+ data.tar.gz: a1f9e7eb20967cadd0d7336fde012be7967abe58
5
+ SHA512:
6
+ metadata.gz: 14f0352810e722d6fc479bd477e98b6d1004e444dde99fe8e30a7bfbcaa93185ff905f16744f9354cbf5da1588720c8f28f7f7435e87e339ae053868089b7c5f
7
+ data.tar.gz: 8dc44d5bb0b63252e58b304dd84b4d3809cef9e3b94af1e1d804e35f0dd3b4e6a0fb303407919eb83d4a6b99e07cb8bce2a986a87ae5397768420b02197790ef
data/bin/owssh ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'json'
5
+ require 'pp'
6
+
7
+ # Export environment variables for AWS CLI here
8
+ $debug = false
9
+ $ssh_key_file = "~/.ssh/id_rsa_dev"
10
+ $owssh_config = "~/.owssh_conf"
11
+
12
+ if ARGV.empty?
13
+ puts "Usage:"
14
+ puts "owssh list - List all environments"
15
+ puts "owssh describe - Show details of instances in all stacks"
16
+ puts "owssh describe [stack] - Show details of a specific stack"
17
+ puts "owssh [stack] [instance] - SSH to an instance in a stack"
18
+ exit
19
+ end
20
+
21
+ $stacks = {}
22
+ $instances = {}
23
+
24
+ stacks_json = JSON.parse(`aws opsworks describe-stacks`)
25
+
26
+ stacks_json['Stacks'].each do |stack|
27
+ if $debug then puts "Stack Name: #{stack['Name'].gsub(' ','_').downcase} Stack ID: #{stack['StackId']}" end
28
+ stack_name = stack['Name'].gsub(' ','_').downcase
29
+ $stacks[stack_name.to_s] = stack['StackId']
30
+ end
31
+
32
+ if ARGV[0] == "list" then
33
+ puts " --- Stacks ---"
34
+ $stacks.each do |stack_name, id|
35
+ puts "Name: #{stack_name} ID: #{id}"
36
+ end
37
+ exit
38
+ elsif ARGV[0] == "describe" && ARGV[1].nil? then
39
+ $stacks.each do |stack_name, id|
40
+ puts "Stack: #{stack_name} ID: #{id}"
41
+ instances_json = JSON.parse(`aws opsworks describe-instances --stack-id #{id}`)
42
+ instances_json['Instances'].each do |instance|
43
+ ip = instance['ElasticIp'] || instance['PublicIp']
44
+ puts "Name: #{instance['Hostname']} IP: #{ip}"
45
+ end
46
+ end
47
+ exit
48
+ elsif ARGV[0] == "describe" && !ARGV[1].nil? then
49
+ stack_arg = ARGV[1]
50
+ if $stacks.has_key?(ARGV[1].downcase.to_s) then
51
+ if $debug then puts "Stack ID: #{$stacks[stack_arg]}" end
52
+ puts "Getting data for Stack: #{stack_arg}"
53
+ instances_json = JSON.parse(`aws opsworks describe-instances --stack-id #{$stacks[stack_arg]}`)
54
+ instances_json['Instances'].each do |instance|
55
+ ip = instance['ElasticIp'] || instance['PublicIp'] || "DOWN"
56
+ puts "Name: #{instance['Hostname']} IP: #{ip}"
57
+ end
58
+ elsif
59
+ puts "Unable to find stack named '#{ARGV[1]}'"
60
+ exit
61
+ end
62
+ elsif $stacks.has_key?(ARGV[0].downcase.to_s) then
63
+ if ARGV[1].nil? then
64
+ puts "Please enter an instance name. I.E. rails-app3"
65
+ exit
66
+ end
67
+ stack_arg = ARGV[0].downcase
68
+ instances_json = JSON.parse(`aws opsworks describe-instances --stack-id #{$stacks[stack_arg]}`)
69
+ instances_json['Instances'].each do |instance|
70
+ $instances["#{instance["Hostname"]}"] = instance["PublicIp"]
71
+ end
72
+ if $instances.has_key?(ARGV[1]) then
73
+ puts "Opening connection to #{ARGV[1]}..."
74
+ exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$instances[ARGV[1].to_s]}")
75
+ else
76
+ puts "Instance with name '#{ARGV[1]}' not found"
77
+ exit
78
+ end
79
+ else
80
+ puts "I don't quite understand what you're asking me to do..."
81
+ puts " Try running owssh with no arguments for help!"
82
+ exit
83
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: owssh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Philip Hutchins
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Wrapper for awscli for listing OpsWorks hosts and sshing to them
14
+ email: flipture@gmail.com
15
+ executables:
16
+ - owssh
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/owssh
21
+ homepage: http://phutchins.com/
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.0.3
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: OWssh
45
+ test_files: []
46
+ has_rdoc: