Sha256: 483e251e006bc0d010d0401bf7c992d6acdaa799e7071fe517ebd9879e088eb7

Contents?: true

Size: 1000 Bytes

Versions: 11

Compression:

Stored size: 1000 Bytes

Contents

#
# Run an SSH script
#
module Chimp
  class ExecSSH < Executor
    attr_accessor :ssh_user
    
    def initialize(h={})
      super(h)
      @ssh_user = h[:ssh_user]
    end
    
    def run
      host = @server['ip_address'] || @server['ip-address'] || nil
      @ssh_user ||= "root"
      
      if host == nil
        @server.settings
        host = @server['ip_address'] || @server['ip-address']
      end
      
      run_with_retry do
        Log.debug "ssh #{@ssh_user}@#{host} \"#{@exec}\""
        success = system("ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no #{@ssh_user}@#{host} \"#{@exec}\"")
        
        if not $?.success?
          raise "SSH failed with status: #{$?}"
        end
      end
    end
    
    def describe_work
      return "ExecSSH job_id=#{@job_id} command=\"#{@exec}\" server=\"#{@server['nickname']}\""
    end
    
    def info
      return @exec.to_s
    end
    
    def target
      return @server['nickname']
    end
    
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
right_chimp-1.1.3 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.1.2 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.1.1 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.1.0 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.0.9 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.0.8 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.0.7 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.0.3 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.0.2 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.0.1 lib/right_chimp/exec/ExecSSH.rb
right_chimp-1.0 lib/right_chimp/exec/ExecSSH.rb