Bolt running local script

21 views
Skip to first unread message

Chris Edwards

unread,
Aug 7, 2020, 12:24:30 PM8/7/20
to Puppet Users
Not sure if this is the correct place to post this question but I'll do it anyway....

Hi!  I am trying to have Bolt run a script on my laptop for each target.  I don't want to execute a script on the target.   Obviously I am fairly new to Bolt.  Any help is appreciated.

Thanks,

Chris Edwards

Alex Dreyer

unread,
Aug 7, 2020, 12:43:39 PM8/7/20
to puppet...@googlegroups.com
You'll have to use the localhost target inside a loop in a plan for that.

get_targets($targets).each |$t| {
   run_script('myscript', 'localhost', arguments => [ $t.host ]) 
}

If you convert the script into a task you can use run_task_with to parallelize it but it's probably easier to just write a task or script that accepts an array of host names.

# create a special local target for each remote host.
$local_targets = get_targets($targets).map |t| { get_target("local://$t.host") }
# use run_task_with to execute against all of these against localhost
run_task_with(mytask, $local_targets) |$t| {
  { 'host' => $t.host }
}

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/fb0c2bc4-36f6-457b-b804-e798f7f0f81bo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages