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] $hosts) ⇒ Any

SPDX-License-Identifier: Apache-2.0

Parameters:

  • hosts (Array[Hash])

Returns:

  • (Any)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 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]", :hosts
  end

  def munge_facts(hosts)
    facts_out = Hash.new { |h, k| h[k] = {} }
    hosts.each do |host|
      host.each do |k, v|
        facts_out[host["certname"]][k] = v if k =~ /^facts/ && v
      end
    end
    facts_out
  end
end