Method: Puppet::Node#fact_merge

Defined in:
lib/puppet/node.rb

#fact_merge(facts = nil) ⇒ nil

Merge the node facts with parameters from the node source.

Parameters:

  • facts (optional, Puppet::Node::Facts) (defaults to: nil)

    facts to merge into node parameters. Will query Facts indirection if not supplied.

Returns:

  • (nil)

Raises:

  • (Puppet::Error)

    Raise on failure to retrieve facts if not supplied



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/puppet/node.rb', line 136

def fact_merge(facts = nil)
  begin
    @facts = facts.nil? ? Puppet::Node::Facts.indirection.find(name, :environment => environment) : facts
  rescue => detail
    error = Puppet::Error.new(_("Could not retrieve facts for %{name}: %{detail}") % { name: name, detail: detail }, detail)
    error.set_backtrace(detail.backtrace)
    raise error
  end

  unless @facts.nil?
    @facts.sanitize
    # facts should never modify the environment parameter
    orig_param_env = @parameters[ENVIRONMENT]
    merge(@facts.values)
    @parameters[ENVIRONMENT] = orig_param_env
  end
end