Class: Anvil::SshExecutor
- Inherits:
-
Struct
- Object
- Struct
- Anvil::SshExecutor
- Defined in:
- lib/anvil/ssh_executor.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
Instance Attribute Details
#hostname ⇒ Object
Returns the value of attribute hostname
11 12 13 |
# File 'lib/anvil/ssh_executor.rb', line 11 def hostname @hostname end |
#logger ⇒ Object
Returns the value of attribute logger
11 12 13 |
# File 'lib/anvil/ssh_executor.rb', line 11 def logger @logger end |
#user ⇒ Object
Returns the value of attribute user
11 12 13 |
# File 'lib/anvil/ssh_executor.rb', line 11 def user @user end |
Instance Method Details
#call(&block) ⇒ Object
12 13 14 15 |
# File 'lib/anvil/ssh_executor.rb', line 12 def call &block @connection = Net::SSH.start hostname, user, use_agent: true, verify_host_key: :accept_new block.call self end |
#exec!(script, category = "") ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/anvil/ssh_executor.rb', line 17 def exec! script, category = "" @connection.exec! script do |channel, stream, data| data.to_s.split("\n") do |line| logger&.info line, category end end end |