octosh 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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/octosh-*.gem
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ notifications:
5
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'net-ssh', '2.6.1'
4
+
5
+ group :test do
6
+ gem 'rake', '0.9.2.2'
7
+ gem 'rspec', '2.12.0'
8
+ gem 'rspec-mocks', '2.12.0'
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,23 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ net-ssh (2.6.1)
6
+ rake (0.9.2.2)
7
+ rspec (2.12.0)
8
+ rspec-core (~> 2.12.0)
9
+ rspec-expectations (~> 2.12.0)
10
+ rspec-mocks (~> 2.12.0)
11
+ rspec-core (2.12.0)
12
+ rspec-expectations (2.12.0)
13
+ diff-lcs (~> 1.1.3)
14
+ rspec-mocks (2.12.0)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ net-ssh (= 2.6.1)
21
+ rake (= 0.9.2.2)
22
+ rspec (= 2.12.0)
23
+ rspec-mocks (= 2.12.0)
data/README.md ADDED
@@ -0,0 +1,6 @@
1
+ Octosh
2
+ =====
3
+
4
+ [![Build Status](https://secure.travis-ci.org/BrianMMcClain/octosh.png)](http://travis-ci.org/BrianMMcClain/octosh)
5
+
6
+ For when you feel like you need eight arms to manage your servers
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = 'spec/*_spec.rb'
7
+ spec.rspec_opts = ['--backtrace', '--format documentation']
8
+ end
9
+
10
+ task :default => :spec
data/bin/octoch ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.dirname(__FILE__) + '/../lib'
3
+
4
+ require "rubygems"
5
+ require "octosh/cli"
6
+
7
+ Octosh::CLI.start
data/lib/octosh/cli.rb ADDED
@@ -0,0 +1,68 @@
1
+ require 'optparse'
2
+ require 'ostruct'
3
+
4
+ $:.push File.dirname(__FILE__) + '../'
5
+ require 'octosh'
6
+
7
+ module Octosh
8
+ class CLI
9
+
10
+ class MODE
11
+ CONFIG = :config
12
+ INLINE = :inline
13
+ end
14
+
15
+ def self.start
16
+ options = OpenStruct.new
17
+
18
+ optparse = OptionParser.new do|opts|
19
+ opts.banner = "Usage: octosh [options] [octo config file]"
20
+
21
+ opts.on('-c', '--config FILE', 'Octo config file') do |file|
22
+ options.config = file
23
+ end
24
+
25
+ opts.on('-b', '--bash COMMAND', 'Explicitly define a command(s) to run on all hosts (Requires --hosts switch)') do |bash|
26
+ options.bash = bash
27
+ end
28
+
29
+ opts.on('-s', '--script SCRIPT', 'Path to script to run on all hosts (Requires --hosts switch)') do |script|
30
+ options.script = script
31
+ end
32
+
33
+ opts.on('-r', '--hosts USER@HOST,USER@HOST', Array, 'Lists of hosts to use when using inline execution (with -b or -s switches)') do |list|
34
+ options.hosts = list
35
+ end
36
+
37
+ opts.on('-u', '--user', 'User to use when a user isn\'t defined in the --hosts list (ie. just IP address)') do |user|
38
+ options.default_user = user
39
+ end
40
+
41
+ opts.on_tail('-h', '--help', 'Display this screen' ) do
42
+ puts opts
43
+ exit
44
+ end
45
+ end.parse!
46
+
47
+ puts options.config
48
+
49
+ if not ARGV.empty? and not options.config
50
+ options.config = ARGV[0]
51
+ options.mode = Octosh::CLI::MODE::CONFIG
52
+ elsif ARGV.empty? and options.config
53
+ options.mode = Octosh::CLI::MODE::CONFIG
54
+ elsif not ARGV.empty? and options.config
55
+ puts "Two config files specified (#{options.config} and #{ARGV[0]}), using explicit config file (#{options.config})"
56
+ options.mode = Octosh::CLI::MODE::CONFIG
57
+ elsif (options.bash or options.script) and options.hosts
58
+ puts "Using inline execution"
59
+ options.mode = Octosh::CLI::MODE::INLINE
60
+ else
61
+ puts "Error -- Must either provide an Octo config file or arguments for inline execution (--hosts along with -b or -s)"
62
+ exit
63
+ end
64
+
65
+ puts options.inspect
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,3 @@
1
+ module Octosh
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ module Octosh
2
+ class Worker
3
+
4
+ attr_reader :host, :user, :password
5
+
6
+ def initialize(host, user, pass)
7
+ @host = host
8
+ @user = user
9
+ @password = pass
10
+ end
11
+
12
+ def exec(command)
13
+ output = ""
14
+ Net::SSH.start(@host, @user, :password => @password) do |ssh|
15
+ output = ssh.exec!(command)
16
+ end
17
+
18
+ return output
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ Dir[File.expand_path("../worker/*.rb", __FILE__)].each do |file|
2
+ require file
3
+ end
data/lib/octosh.rb ADDED
@@ -0,0 +1 @@
1
+ require 'octosh/worker'
data/octosh.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/octosh/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Brian McClain"]
6
+ gem.email = ["brianmmcclain@gmail.com"]
7
+ gem.description = %q{Octosh}
8
+ gem.summary = gem.summary
9
+ gem.homepage = "https://github.com/BrianMMcClain/octosh"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "octosh"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Octosh::VERSION
17
+ end
@@ -0,0 +1 @@
1
+ require_relative '../lib/octosh'
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Octosh::Worker do
4
+
5
+ it "should instantiate" do
6
+ worker = Octosh::Worker.new('127.0.0.1', 'bob', 'password')
7
+
8
+ worker.should_not be_nil
9
+ worker.host.should == '127.0.0.1'
10
+ worker.user.should == 'bob'
11
+ worker.password.should == 'password'
12
+ end
13
+
14
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octosh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brian McClain
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Octosh
15
+ email:
16
+ - brianmmcclain@gmail.com
17
+ executables:
18
+ - octoch
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - .travis.yml
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - README.md
27
+ - Rakefile
28
+ - bin/octoch
29
+ - lib/octosh.rb
30
+ - lib/octosh/cli.rb
31
+ - lib/octosh/version.rb
32
+ - lib/octosh/worker.rb
33
+ - lib/octosh/worker/worker.rb
34
+ - octosh.gemspec
35
+ - spec/spec_helper.rb
36
+ - spec/worker_spec.rb
37
+ homepage: https://github.com/BrianMMcClain/octosh
38
+ licenses: []
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 1.8.24
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: ''
61
+ test_files:
62
+ - spec/spec_helper.rb
63
+ - spec/worker_spec.rb