Puppet Function: puppetdb::munge_facts

Defined in:
modules/puppetdb/lib/puppet/functions/puppetdb/munge_facts.rb
Function type:
Ruby 4.x API

Overview

puppetdb::munge_facts(Array[Hash] $facts)Any

SPDX-License-Identifier: Apache-2.0

Parameters:

  • facts (Array[Hash])

Returns:

  • (Any)


2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'modules/puppetdb/lib/puppet/functions/puppetdb/munge_facts.rb', line 2

Puppet::Functions.create_function(:'puppetdb::munge_facts') do
  dispatch :munge_facts do
    param 'Array[Hash]', :facts
  end

  def munge_facts(facts)
    facts_out = Hash.new {|h, k| h[k] = {}}
    facts.each do |f|
      facts_out[f['certname']][f['name']] = f['value']
    end
    facts_out
  end
end