Sha256: d74149194a48bf6f67f232b6687db6247f04aec6600ec49162a21654c43a6957

Contents?: true

Size: 735 Bytes

Versions: 30

Compression:

Stored size: 735 Bytes

Contents

# frozen_string_literal: true

require 'bolt/error'

# Returns the facts hash for a target.
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) { nil }

    unless inventory
      raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
        Puppet::Pops::Issues::TASK_MISSING_BOLT, action: _('get facts for a target')
      )
    end

    executor = Puppet.lookup(:bolt_executor) { nil }
    executor&.report_function_call('facts')

    inventory.facts(target)
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
bolt-1.19.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.18.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.17.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.16.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.15.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.14.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.13.1 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.13.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.12.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.11.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.10.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.9.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.8.1 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.8.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.7.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.6.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.5.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.4.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.3.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-1.2.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb