Sha256: da7164599974cf50ca8042e4b24a1f79c0182e3500fedd582ff61ad93e412c34

Contents?: true

Size: 1003 Bytes

Versions: 19

Compression:

Stored size: 1003 Bytes

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)
    executor.report_function_call(self.class.name)

    inventory.add_facts(target, facts)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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