Class: Bolt::Transport::Remote
- Defined in:
- lib/bolt/transport/remote.rb
Constant Summary
Constants inherited from Base
Base::ENVIRONMENT_METHODS, Base::STDIN_METHODS
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .default_options ⇒ Object
-
.filter_options(unfiltered) ⇒ Object
The options for the remote transport not defined.
- .validate(options) ⇒ Object
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 = {}) ⇒ Object
Cannot batch because arugments differ.
Methods inherited from Base
#assert_batch_size_one, #batch_command, #batch_connected?, #batch_script, #batch_task, #batch_upload, #batches, #connected?, #default_input_method, #envify_params, options, #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
26 27 28 29 30 |
# File 'lib/bolt/transport/remote.rb', line 26 def initialize(executor) super() @executor = executor end |
Class Method Details
.default_options ⇒ Object
14 15 16 |
# File 'lib/bolt/transport/remote.rb', line 14 def self. { 'run-on' => 'localhost' } end |
.filter_options(unfiltered) ⇒ Object
The options for the remote transport not defined.
10 11 12 |
# File 'lib/bolt/transport/remote.rb', line 10 def self.(unfiltered) unfiltered end |
.validate(options) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/bolt/transport/remote.rb', line 18 def self.validate() # This will fail when validating global config # unless options['device-type'] # raise Bolt::ValidationError, 'Must specify device-type for devices' # end end |
Instance Method Details
#get_proxy(target) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bolt/transport/remote.rb', line 32 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 = {}) ⇒ Object
Cannot batch because arugments differ
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bolt/transport/remote.rb', line 45 def run_task(target, task, arguments, = {}) proxy_target = get_proxy(target) transport = @executor.transport(proxy_target.protocol) arguments = arguments.merge('_target' => target.to_h.reject { |_, v| v.nil? }) remote_task = task.remote_instance result = transport.run_task(proxy_target, remote_task, arguments, ) Bolt::Result.new(target, value: result.value) end |