Class: Bolt::Transport::SSH
- Defined in:
- lib/bolt/transport/ssh.rb,
lib/bolt/transport/ssh/connection.rb,
lib/bolt/transport/ssh/exec_connection.rb
Defined Under Namespace
Classes: Connection, ExecConnection
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ SSH
constructor
A new instance of SSH.
- #with_connection(target) ⇒ Object
Methods inherited from Simple
#connected?, #run_command, #run_script, #run_task, #upload
Methods inherited from Base
#assert_batch_size_one, #batch_command, #batch_connected?, #batch_script, #batch_task, #batch_task_with, #batch_upload, #batches, #connected?, #default_input_method, #envify_params, #provided_features, #run_command, #run_script, #run_task, #select_implementation, #select_interpreter, #unwrap_sensitive_args, #upload, #with_events
Constructor Details
#initialize ⇒ SSH
Returns a new instance of SSH.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bolt/transport/ssh.rb', line 9 def initialize super require 'net/ssh' require 'net/scp' begin require 'net/ssh/krb' rescue LoadError logger.debug("Authentication method 'gssapi-with-mic' (Kerberos) is not available.") end @transport_logger = Logging.logger[Net::SSH] @transport_logger.level = :warn end |
Instance Method Details
#with_connection(target) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bolt/transport/ssh.rb', line 23 def with_connection(target) conn = if target.transport_config['ssh-command'] ExecConnection.new(target) else Connection.new(target, @transport_logger) end conn.connect yield conn ensure begin conn&.disconnect rescue StandardError => e logger.info("Failed to close connection to #{target.safe_name} : #{e.}") end end |