Class: Bolt::Transport::Simple

Inherits:
Base
  • Object
show all
Defined in:
lib/bolt/transport/simple.rb

Overview

A simple transport has a single connection per target and delegates its operation to a target-specific shell.

Direct Known Subclasses

Docker, LXD, Local, SSH, WinRM

Instance Attribute Summary

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#assert_batch_size_one, #batch_command, #batch_connected?, #batch_download, #batch_script, #batch_task, #batch_task_with, #batch_upload, #batches, #default_input_method, #initialize, #provided_features, #select_implementation, #select_interpreter, #unwrap_sensitive_args, #with_events

Constructor Details

This class inherits a constructor from Bolt::Transport::Base

Instance Method Details

#connected?(target) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/bolt/transport/simple.rb', line 17

def connected?(target)
  with_connection(target) { true }
rescue Bolt::Node::ConnectError
  false
end

#download(target, source, destination, options = {}) ⇒ Object



35
36
37
38
39
# File 'lib/bolt/transport/simple.rb', line 35

def download(target, source, destination, options = {})
  with_connection(target) do |conn|
    conn.shell.download(source, destination, options)
  end
end

#run_command(target, command, options = {}, position = []) ⇒ Object



23
24
25
26
27
# File 'lib/bolt/transport/simple.rb', line 23

def run_command(target, command, options = {}, position = [])
  with_connection(target) do |conn|
    conn.shell.run_command(command, options, position)
  end
end

#run_script(target, script, arguments, options = {}, position = []) ⇒ Object



41
42
43
44
45
# File 'lib/bolt/transport/simple.rb', line 41

def run_script(target, script, arguments, options = {}, position = [])
  with_connection(target) do |conn|
    conn.shell.run_script(script, arguments, options, position)
  end
end

#run_task(target, task, arguments, options = {}, position = []) ⇒ Object



47
48
49
50
51
# File 'lib/bolt/transport/simple.rb', line 47

def run_task(target, task, arguments, options = {}, position = [])
  with_connection(target) do |conn|
    conn.shell.run_task(task, arguments, options, position)
  end
end

#upload(target, source, destination, options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/bolt/transport/simple.rb', line 29

def upload(target, source, destination, options = {})
  with_connection(target) do |conn|
    conn.shell.upload(source, destination, options)
  end
end

#with_connection(_target) ⇒ Object

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/bolt/transport/simple.rb', line 13

def with_connection(_target)
  raise NotImplementedError, "with_connection() must be implemented by the transport class"
end