Sha256: b324c07268d8f714395039db3b4538b8c7c5953b03f4ba8ba90d6f7393d1f3f2
Contents?: true
Size: 1.15 KB
Versions: 26
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require 'bolt/error' # Deep merges a hash of facts with the existing facts on a target. 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( 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 executor = Puppet.lookup(:bolt_executor) { nil } executor&.report_function_call('add_facts') inventory.add_facts(target, facts) end end
Version data entries
26 entries across 26 versions & 1 rubygems