Sha256: c0401a70dc36b464c37ad756f16569c7af5bc4bff6b6e211b5f854e085987a96

Contents?: true

Size: 835 Bytes

Versions: 37

Compression:

Stored size: 835 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 || nil
      @ssh_user ||= "root"

      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

37 entries across 37 versions & 1 rubygems

Version Path
right_chimp-2.4 lib/right_chimp/exec/exec_ssh.rb
right_chimp-2.3.2 lib/right_chimp/exec/exec_ssh.rb
right_chimp-2.3.1 lib/right_chimp/exec/exec_ssh.rb
right_chimp-2.3 lib/right_chimp/exec/exec_ssh.rb
right_chimp-2.2.2 lib/right_chimp/exec/exec_ssh.rb
right_chimp-2.2.1 lib/right_chimp/exec/exec_ssh.rb
right_chimp-2.2 lib/right_chimp/exec/exec_ssh.rb
right_chimp-2.1.28 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.27 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.26 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.25.2 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.25 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.24 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.22.2 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.22.1 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.22 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.21 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.19.1 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.19 lib/right_chimp/exec/ExecSSH.rb
right_chimp-2.1.18 lib/right_chimp/exec/ExecSSH.rb