Class: Bolt::Transport::Remote
- Defined in:
- lib/bolt/transport/remote.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #get_proxy(target) ⇒ Object
-
#initialize(executor) ⇒ Remote
constructor
TODO: this should have access to inventory so target doesn’t have to.
-
#run_task(target, task, arguments, options = {}, position = []) ⇒ Object
Cannot batch because arugments differ.
Methods inherited from Base
#assert_batch_size_one, #batch_command, #batch_connected?, #batch_download, #batch_script, #batch_task, #batch_task_with, #batch_upload, #batches, #connected?, #default_input_method, #download, #provided_features, #run_command, #run_script, #select_implementation, #select_interpreter, #unwrap_sensitive_args, #upload, #with_events
Constructor Details
#initialize(executor) ⇒ Remote
TODO: this should have access to inventory so target doesn’t have to
10 11 12 13 14 |
# File 'lib/bolt/transport/remote.rb', line 10 def initialize(executor) super() @executor = executor end |
Instance Method Details
#get_proxy(target) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bolt/transport/remote.rb', line 16 def get_proxy(target) inventory = target.inventory raise "Target was created without inventory? Not get_targets?" unless inventory proxy = inventory.get_targets(target.['run-on'] || 'localhost').first if proxy.transport == 'remote' msg = "#{proxy.name} is not a valid run-on target for #{target.name} since is also remote." raise Bolt::Error.new(msg, 'bolt/invalid-remote-target') end proxy end |
#run_task(target, task, arguments, options = {}, position = []) ⇒ Object
Cannot batch because arugments differ
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bolt/transport/remote.rb', line 29 def run_task(target, task, arguments, = {}, position = []) proxy_target = get_proxy(target) transport = @executor.transport(proxy_target.transport) arguments = arguments.merge('_target' => target.to_h.compact) remote_task = task.remote_instance result = transport.run_task(proxy_target, remote_task, arguments, , position) Bolt::Result.new(target, value: result.value, action: 'task', object: task.name) end |