Sha256: d619b0b8b0f9e8443d10af0be0e64c3e3a632ca797cda0f3b86ebeb764af164c

Contents?: true

Size: 794 Bytes

Versions: 10

Compression:

Stored size: 794 Bytes

Contents

# frozen_string_literal: true

require 'bolt/error'

# Returns the facts hash for a target.
# This functions takes one parameter, the target to get facts for
Puppet::Functions.create_function(:facts) do
  dispatch :facts do
    param 'Target', :target
    return_type 'Hash[String, Data]'
  end

  def facts(target)
    unless Puppet[:tasks]
      raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
        Puppet::Pops::Issues::TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, operation: 'facts'
      )
    end

    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

    inventory.facts(target)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bolt-0.20.6 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-0.20.5 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-0.20.3 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-0.20.2 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-0.20.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-0.19.1 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-0.19.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-0.18.2 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-0.18.1 bolt-modules/boltlib/lib/puppet/functions/facts.rb
bolt-0.18.0 bolt-modules/boltlib/lib/puppet/functions/facts.rb