Sha256: efbd788f99e912f0ecaacfd08cb3a6a3532a12147defed44a8bf6db37f4e0c82

Contents?: true

Size: 997 Bytes

Versions: 53

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

require 'bolt/error'

# Returns the facts hash for a target.
#
# Using the `facts` function does not automatically collect facts for a target,
# and will only return facts that are currently set in the inventory. To collect
# facts from a target and set them in the inventory, run the
# [facts](writing_plans.md#collect-facts-from-targets) plan or
# [puppetdb_fact](writing_plans.md#collect-facts-from-puppetdb) plan.
Puppet::Functions.create_function(:facts) do
  # @param target A target.
  # @return The target's facts.
  # @example Getting facts
  #   facts($target)
  dispatch :facts do
    param 'Target', :target
    return_type 'Hash[String, Data]'
  end

  def facts(target)
    inventory = Puppet.lookup(:bolt_inventory)
    # Bolt executor not expected when invoked from apply block
    executor = Puppet.lookup(:bolt_executor) { nil }
    # Send Analytics Report
    executor&.report_function_call(self.class.name)

    inventory.facts(target)
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
bolt-4.0.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.29.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.28.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.27.4 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.27.2 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.27.1 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.26.2 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.26.1 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.25.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.24.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.23.1 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.23.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.22.1 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.22.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.21.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.20.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.19.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.18.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.17.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-3.16.1 bolt-modules/boltlib/lib/puppet/functions/facts.rb