Puppet Function: puppetdb::query_facts

Defined in:
modules/puppetdb/functions/query_facts.pp
Function type:
Puppet Language

Overview

puppetdb::query_facts(Array[String[1]] $filter, Optional[String[1]] $subquery = undef)Hash[Stdlib::Fqdn, Hash]

SPDX-License-Identifier: Apache-2.0

Parameters:

  • filter (Array[String[1]])

    a hash of fact name to fetch

  • a

    pql subquery to apply to the query

  • subquery (Optional[String[1]]) (defaults to: undef)

Returns:

  • (Hash[Stdlib::Fqdn, Hash])


5
6
7
8
9
10
11
12
13
14
15
16
# File 'modules/puppetdb/functions/query_facts.pp', line 5

function puppetdb::query_facts(
    Array[String[1]]    $filter,
    Optional[String[1]] $subquery = undef,
) >> Hash[Stdlib::Fqdn, Hash] {
    $_subquery = $subquery ? {
        undef   => '',
        default => " and ${subquery}"
    }
    $filter_str = $filter.map |$filter| { "\"${filter}\"" }.join(',')
    $pql = "facts[certname, name, value] { name in [${filter_str}] ${_subquery} }"
    puppetdb::munge_facts(wmflib::puppetdb_query($pql))
}