Puppet Plan: patching::puppet_facts

Defined in:
plans/puppet_facts.pp

Summary

Plan thatr runs 'puppet facts' on the targets and sets them as facts on the Target objects.

Overview

This is inspired by: github.com/puppetlabs/puppetlabs-facts/blob/master/plans/init.pp Except instead of just running ‘facter` it runs `puppet facts` to set additional facts that are only present when in the context of puppet.

Under the hood it is executeing the ‘patching::puppet_facts` task.

Parameters:

  • targets (TargetSpec)

    Set of targets to run against.

Returns:

  • (ResultSet)

    The results from the execution of the ‘patching::puppet_facts` task.



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

plan patching::puppet_facts(
  TargetSpec $targets
) {
  $result_set = run_task('patching::puppet_facts', $targets)
  # puppet facts returns a structure like:
  #   name: mynodename.domain.tld
  #   values:
  #     fact1: abc
  #     fact2: def
  #
  # We only want to set the "values" as facts on the node
  $result_set.each |$result| {
    # Debian systems to not have values param they are just in the value return
    if 'values' in $result.value {
      $target_fact_values = $result.value['values']
    } else {
      $target_fact_values = $result.value
    }

    add_facts($result.target, $target_fact_values)
  }
  return $result_set
}