Sha256: 0e28d15fcf481a75f0cbce25d8d62983a7d6159505ea3e10e9702b7f548bd1c9
Contents?: true
Size: 978 Bytes
Versions: 1
Compression:
Stored size: 978 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 => 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-puppet-0.4.2 | lib/utils/ssh.rb |