Sha256: 14094e404d8eb3b36a3e2927c7f1beae23938481e23cb2f8f5c828d7ce2d6dd8

Contents?: true

Size: 770 Bytes

Versions: 10

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

require 'bolt/error'

# Deep merges a hash of facts with the existing facts has on a target.

Puppet::Functions.create_function(:add_facts) do
  dispatch :add_facts do
    param 'Target', :target
    param 'Hash', :facts
  end

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

    inventory = Puppet.lookup(:bolt_inventory) { nil }

    unless inventory
      raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
        Puppet::Pops::Issues::TASK_MISSING_BOLT, action: _('add facts')
      )
    end

    inventory.add_facts(target, facts)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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