Sha256: 7e3e3aacfb7d454425a8fc9df8a99fc9357941b7d0548f777973578c509ffd0f

Contents?: true

Size: 1018 Bytes

Versions: 16

Compression:

Stored size: 1018 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 The target's new facts.
  # @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 'Hash[String, Data]'
  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

16 entries across 16 versions & 1 rubygems

Version Path
bolt-1.33.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.32.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.31.1 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.31.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.30.1 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.30.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.29.1 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.29.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.28.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.27.1 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.27.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.26.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.25.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.24.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.23.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb
bolt-1.22.0 bolt-modules/boltlib/lib/puppet/functions/add_facts.rb