Skip to content

Commit

Permalink
(maint) run plan: Allow environment and noop option
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jan 31, 2023
1 parent 84f0114 commit 53cc321
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plans/run.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Starts a Puppet agent run on the specified targets.
# Note: This plan may cause issues when run in Puppet Enterprise.
# @param targets The targets to start a Puppet agent run on.
# @param noop if true, all runs will use --noop
# @param environment the desired puppet code environment
plan puppet_agent::run (
TargetSpec $targets
TargetSpec $targets,
Boolean $noop = false,
Optional[String[1]] $environment = undef,
) {
# Check which targets have the agent installed by checking
# the version of the agent. No point in trying to run the
Expand Down Expand Up @@ -53,11 +57,20 @@
}

# Run the agent on all targets that have the agent installed.
$arg_env = $environment ? {
Undef => {},
default => {'environment' => $environment, },
}
$arg_noop = $noop ? {
true => { 'noop' => true, },
default => {},
}
$args = $arg_env + $arg_noop + {'_catch_errors' => true }
$run_results = run_task(
'puppet_agent::run',
$agent_results.targets,
'Run Puppet agent',
'_catch_errors' => true
$args,
)

# Merge all of the results into a single ResultSet so each
Expand Down

0 comments on commit 53cc321

Please sign in to comment.