Class: Bolt::Transport::SSH
- Defined in:
- lib/bolt/transport/ssh.rb,
lib/bolt/transport/ssh/connection.rb
Defined Under Namespace
Classes: Connection
Constant Summary
Constants inherited from Base
Base::ENVIRONMENT_METHODS, Base::STDIN_METHODS
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #connected?(target) ⇒ Boolean
-
#initialize ⇒ SSH
constructor
A new instance of SSH.
- #provided_features ⇒ Object
- #with_connection(target) ⇒ Object
Methods inherited from Sudoable
#make_wrapper_stringio, #run_command, #run_script, #run_task, sudo_prompt, #upload
Methods inherited from Base
#assert_batch_size_one, #batch_command, #batch_connected?, #batch_script, #batch_task, #batch_upload, #batches, #default_input_method, #envify_params, #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.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bolt/transport/ssh.rb', line 15 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
#connected?(target) ⇒ Boolean
42 43 44 45 46 |
# File 'lib/bolt/transport/ssh.rb', line 42 def connected?(target) with_connection(target) { true } rescue Bolt::Node::ConnectError false end |
#provided_features ⇒ Object
11 12 13 |
# File 'lib/bolt/transport/ssh.rb', line 11 def provided_features ['shell'] end |
#with_connection(target) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bolt/transport/ssh.rb', line 30 def with_connection(target) conn = Connection.new(target, @transport_logger) conn.connect yield conn ensure begin conn&.disconnect rescue StandardError => e logger.info("Failed to close connection to #{target.safe_name} : #{e.}") end end |