Commit 719efae
committed
Add server facts when looking up values
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#L3901 parent 8068bce commit 719efae
File tree
3 files changed
+11
-0
lines changed- lib/puppet/application
- spec
- fixtures/unit/application/environments/production/data
- unit/application
3 files changed
+11
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
403 | 404 | | |
404 | 405 | | |
405 | 406 | | |
| 407 | + | |
406 | 408 | | |
407 | 409 | | |
408 | 410 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
549 | 556 | | |
550 | 557 | | |
551 | 558 | | |
| |||
0 commit comments