Sha256: fd10cb011b67b2c46495d42ac46aaebb65bd5096daa234f2fa0f6d0b92bc5828
Contents?: true
Size: 1.19 KB
Versions: 7
Compression:
Stored size: 1.19 KB
Contents
module Utils # Utility methods for doing things over SSH module SSH # Intelligently do some things over SSH def over_ssh(opts = {}) result = {} fail "MissingSSHHost" unless opts[:host] fail "MissingSSHUser" unless opts[:user] opts[:timeout] ||= 300 # default to a 5 minute timeout remote = Rye::Box.new( opts[:host], user: opts[:user], auth_methods: ['publickey'], password_prompt: false, error: STDOUT # send STDERR to STDOUT for things that actually print ) exception = nil # Getting serious about not crashing Lita... output = begin Timeout::timeout(opts[:timeout]) do yield remote # pass our host back to the user to work with end rescue Rye::Err => e exception = e rescue StandardError => e exception = e rescue Exception => e exception = e ensure remote.disconnect end if exception result[:exception] = exception else result[:exit_status] = output.exit_status result[:stdout] = output.stdout result[:stderr] = output.stderr end return result end end end
Version data entries
7 entries across 7 versions & 1 rubygems