modules/boltlib/lib/puppet/functions/run_task.rb in bolt-0.11.0 vs modules/boltlib/lib/puppet/functions/run_task.rb in bolt-0.12.0
- old
+ new
@@ -23,11 +23,11 @@
optional_param 'Hash[String[1], Any]', :task_args
block_param
end
def run_task(task_name, targets, task_args = nil)
- Puppet::Pops::Types::ExecutionResult.from_bolt(
+ Bolt::ExecutionResult.from_bolt(
run_task_raw(task_name, targets, task_args)
)
end
def run_task_raw(task_name, targets, task_args = nil, &block)
@@ -56,12 +56,20 @@
task_signature.runnable_with?(use_args) do |mismatch|
raise Puppet::ParseError, mismatch
end || (raise Puppet::ParseError, 'Task parameters did not match')
task = task_signature.task
+ if executor.noop
+ if task.supports_noop
+ use_args['_noop'] = true
+ else
+ raise Puppet::ParseError, 'Task does not support noop'
+ end
+ end
+
# Ensure that that given targets are all Target instances
targets = [targets] unless targets.is_a?(Array)
- targets = targets.flatten.map { |t| t.is_a?(String) ? Puppet::Pops::Types::TypeFactory.target.create(t) : t }
+ targets = targets.flatten.map { |t| t.is_a?(String) ? Bolt::Target.new(t) : t }
if targets.empty?
call_function('debug', "Simulating run of task #{task.name} - no targets given - no action taken")
Puppet::Pops::EMPTY_HASH
else
# TODO: Awaits change in the executor, enabling it receive Target instances