Sha256: 8cbc15733fce6b27c66d905df147fabae81ac6e9f0ff7d19de93fdcce22c2a45

Contents?: true

Size: 1.01 KB

Versions: 32

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require 'bolt/error'

# Deep merges a hash of facts with the existing facts on a target.
#
# > **Note:** Not available in apply block
Puppet::Functions.create_function(:add_facts) do
  # @param target A target.
  # @param facts A hash of fact names to values that may include structured facts.
  # @return A `Target` object.
  # @example Adding facts to a target
  #   add_facts($target, { 'os' => { 'family' => 'windows', 'name' => 'windows' } })
  dispatch :add_facts do
    param 'Target', :target
    param 'Hash', :facts
    return_type 'Target'
  end

  def add_facts(target, facts)
    unless Puppet[:tasks]
      raise Puppet::ParseErrorWithIssue
        .from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, action: 'add_facts')
    end

    inventory = Puppet.lookup(:bolt_inventory)
    executor = Puppet.lookup(:bolt_executor)
    # Send Analytics Report
    executor.report_function_call(self.class.name)

    inventory.add_facts(target, facts)
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
bolt-3.1.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-3.0.1 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-3.0.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.44.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.42.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.40.2 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.40.1 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.38.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.37.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.36.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.35.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.34.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.33.2 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.33.1 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.32.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.31.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.30.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.29.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.28.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-2.27.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb