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 +1 -0
 - data/.travis.yml +5 -0
 - data/Gemfile +9 -0
 - data/Gemfile.lock +23 -0
 - data/README.md +6 -0
 - data/Rakefile +10 -0
 - data/bin/octoch +7 -0
 - data/lib/octosh/cli.rb +68 -0
 - data/lib/octosh/version.rb +3 -0
 - data/lib/octosh/worker/worker.rb +21 -0
 - data/lib/octosh/worker.rb +3 -0
 - data/lib/octosh.rb +1 -0
 - data/octosh.gemspec +17 -0
 - data/spec/spec_helper.rb +1 -0
 - data/spec/worker_spec.rb +14 -0
 - metadata +63 -0
 
    
        data/.gitignore
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            pkg/octosh-*.gem
         
     | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        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
    
    
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/octoch
    ADDED
    
    
    
        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,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
         
     | 
    
        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
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require_relative '../lib/octosh'
         
     | 
    
        data/spec/worker_spec.rb
    ADDED
    
    | 
         @@ -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
         
     |