Puppet Plan: patching::get_facts

Defined in:
plans/get_facts.pp

Summary

Sets patching facts on targets

Overview

Examples:

Get the patching_group fact (default)

bolt plan run patching::get_facts --targets xxx

Get different facts

bolt plan run patching::get_facts --targets xxx names='["fact1", "fact2"]'

Parameters:

  • targets (TargetSpec)

    Set of targets to run against.

  • names (Variant[String, Array[String]]) (defaults to: ['patching_group'])

    Name or list of fact names to retrieve from the targets



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'plans/get_facts.pp', line 15

plan patching::get_facts (
  TargetSpec $targets,
  Variant[String, Array[String]] $names = ['patching_group'],
) {
  # this will set all of the facts on the targets if they have Puppet or not
  $_targets = run_plan('patching::get_targets', $targets)

  # make sure facts is an array so we can treat it consistently
  if $names =~ Array {
    $_names = $names
  }
  else {
    $_names = [$names]
  }

  $_results = $_targets.map |$t| {
    $target_facts = $_names.reduce({}) |$memo, $n| {
      $memo + {$n => facts($t)[$n]}
    }
    Result($t, $target_facts)
  }
  return ResultSet($_results)
}