Sha256: e6dbab293f2699dd0d62b46ead26157b7f6573b4b1607b0dbd66aa3ddf5a4fa3

Contents?: true

Size: 966 Bytes

Versions: 19

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

require 'bolt/error'

# Collects facts based on a list of certnames.
#
# If a node is not found in PuppetDB, it's included in the returned hash with an empty facts hash.
# Otherwise, the node is included in the hash with a value that is a hash of its facts.
Puppet::Functions.create_function(:puppetdb_fact) do
  # @param certnames Array of certnames.
  # @return A hash of certname to facts hash for each matched Target.
  # @example Get facts for nodes
  #   puppetdb_fact(['app.example.com', 'db.example.com'])
  dispatch :puppetdb_fact do
    param 'Array[String]', :certnames
    return_type 'Hash[String, Data]'
  end

  def puppetdb_fact(certnames)
    puppetdb_client = Puppet.lookup(:bolt_pdb_client)
    # Bolt executor not expected when invoked from apply block
    executor = Puppet.lookup(:bolt_executor) { nil }
    executor&.report_function_call(self.class.name)

    puppetdb_client.facts_for_node(certnames)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bolt-2.15.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.14.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.13.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.12.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.11.1 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.11.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.10.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.9.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.8.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.7.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.6.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.5.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.4.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.3.1 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.3.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.2.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.1.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.0.1 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb
bolt-2.0.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb