Sha256: ab667f428576424e4cef77486b3986f751f78515c9ff8cb7a687f1b0cee6f51e

Contents?: true

Size: 810 Bytes

Versions: 5

Compression:

Stored size: 810 Bytes

Contents

plan aggregate::count(
  Optional[String[0]] $task = undef,
  Optional[String[0]] $command = undef,
  Optional[String[0]] $script = undef,
  TargetSpec $nodes,
  Hash[String, Data] $params = {}
) {

  # Validation
  $type_count = [$task, $command, $script].reduce(0) |$acc, $v| {
    if ($v) {
      $acc + 1
    } else {
      $acc
    }
  }

  if ($type_count == 0) {
    fail_plan("Must specify a command, script, or task to run", 'canary/invalid-params')
  }

  if ($type_count > 1) {
    fail_plan("Must specify only one command, script, or task to run", 'canary/invalid-params')
  }

  $res = if ($task) {
    run_task($task, $nodes, $params)
  } elsif ($command) {
    run_command($command, $nodes, $params)
  } elsif ($script) {
    run_script($script, $nodes, $params)
  }

  aggregate::count($res)
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bolt-0.18.1 modules/aggregate/plans/count.pp
bolt-0.18.0 modules/aggregate/plans/count.pp
bolt-0.17.2 modules/aggregate/plans/count.pp
bolt-0.17.1 modules/aggregate/plans/count.pp
bolt-0.17.0 modules/aggregate/plans/count.pp