Sha256: 99676a2ec41a93298d5ed48e8eb88c6ac424b26ee069e3643c729d892acf4d44
Contents?: true
Size: 988 Bytes
Versions: 3
Compression:
Stored size: 988 Bytes
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 ) exception = nil output = begin Timeout::timeout(opts[:timeout]) do yield remote # pass our host back to the user to work with end 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lita-puppet-0.4.1 | lib/utils/ssh.rb |
lita-puppet-0.4.0 | lib/utils/ssh.rb |
lita-puppet-0.3.1 | lib/utils/ssh.rb |