Module: BoltSpec::Run
- Defined in:
- lib/bolt_spec/run.rb
Defined Under Namespace
Classes: BoltRunner
Instance Method Summary collapse
- #run_command(command, targets, params = nil, config: nil, inventory: nil) ⇒ Object
- #run_plan(plan_name, params = nil, config: nil, inventory: nil) ⇒ Object
- #run_task(task_name, targets, params = nil, config: nil, inventory: nil) ⇒ Object
Instance Method Details
#run_command(command, targets, params = nil, config: nil, inventory: nil) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/bolt_spec/run.rb', line 36 def run_command(command, targets, params = nil, config: nil, inventory: nil) result = BoltRunner.with_runner(config, inventory) do |runner| runner.run_command(command, targets, params) end result = result.to_a Bolt::Util.walk_keys(result, &:to_s) end |
#run_plan(plan_name, params = nil, config: nil, inventory: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bolt_spec/run.rb', line 23 def run_plan(plan_name, params = nil, config: nil, inventory: nil) # Users copying code from run_task may forget that targets is not a parameter for run plan params ||= {} raise ArgumentError, "params must be a hash" unless params.is_a?(Hash) result = BoltRunner.with_runner(config, inventory) do |runner| runner.run_plan(plan_name, params || {}) end { "status" => result.status, "value" => JSON.parse(result.value.to_json) } end |
#run_task(task_name, targets, params = nil, config: nil, inventory: nil) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/bolt_spec/run.rb', line 15 def run_task(task_name, targets, params = nil, config: nil, inventory: nil) result = BoltRunner.with_runner(config, inventory) do |runner| runner.run_task(task_name, targets, params || {}) end result = result.to_a Bolt::Util.walk_keys(result, &:to_s) end |