Add server facts when looking up values #9392
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During normal catalog compilation, server facts are added by the
compiler
terminus prior to calling
Puppet::Parser::Compiler.compile
[1]. However, thelookup application directly calls
Compiler.compile
, bypassing thecompiler
terminus[2]. Therefore, server facts weren't being added when running the lookup
command.
Ideally, catalog compilation and the lookup command would compile the catalog in
the same way, but changing that is risky. For that to work, we would need to
pass the already resolved node and facts to the
compiler
terminus and theterminus would need to add server facts to the node. However, the terminus
doesn't add server facts if the node is passed in. It only does that if it
resolves the node using the indirector[3].
Rather than mess with the terminus and break compilation, just load server facts
in the same way that the
compiler
terminus does.[1] https://github.com/puppetlabs/puppet/blob/8.7.0/lib/puppet/indirector/catalog/compiler.rb#L56
[2] https://github.com/puppetlabs/puppet/blob/8.7.0/lib/puppet/application/lookup.rb#L407
[3] https://github.com/puppetlabs/puppet/blob/8.7.0/lib/puppet/indirector/catalog/compiler.rb#L390
Fixes PE-37867