Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 7.x] Add server facts when looking up values #9399

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

joshcooper
Copy link
Contributor

Manual backport of #9392 due to legacy facts in puppet 7

puppet 7.x still uses legacy facts with symbolic fact names, e.g.
value(:hostname)

(cherry picked from commit 8068bce)
During normal catalog compilation, server facts are added by the `compiler`
terminus prior to calling `Puppet::Parser::Compiler.compile`[1]. However, the
lookup application directly calls `Compiler.compile`, bypassing the `compiler`
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 the
terminus 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

(cherry picked from commit 719efae)
@joshcooper joshcooper force-pushed the backport_lookup_server_facts branch from 32fa75d to b8c2736 Compare June 18, 2024 16:49
@joshcooper joshcooper marked this pull request as ready for review June 18, 2024 17:32
@joshcooper joshcooper requested a review from a team as a code owner June 18, 2024 17:32
@mhashizume mhashizume merged commit 19caf04 into puppetlabs:7.x Jun 18, 2024
12 checks passed
@joshcooper joshcooper deleted the backport_lookup_server_facts branch June 18, 2024 17:47
@joshcooper joshcooper added the bug Something isn't working label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants