| Coming back to this... So the question is what to do when trying to lookup a value for a node that isn't ourself (the puppetserver node), we don't have any cached facts for the node, and none were specified on the command line? Currently if you reference a fact, but it's missing then lookup (with --compile) will fail:
[root@pe2019 ~]# puppet lookup message --node bogus --compile |
Error: Could not run: Evaluation Error: Missing title. The title expression resulted in undef (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 31, column: 12)
|
You can make the argument that this behavior is "expected" since we have no way of knowing ahead of time what facts might be needed, and we can't simulate all of them. However, if your hierarchy is defined using facts like trusted.certname, then lookup without compilation can lead to surprises (as described in this ticket). We could try to simulate some "well known" facts, but what if someone follows our docs using the is_virtual fact:
# /etc/puppetlabs/puppet/hiera.yaml |
--- |
:hierarchy: |
- "nodes/%{trusted.certname}" |
- "environment/%{server_facts.environment}" |
- "virtual/%{::is_virtual}" |
- common
|
I think the least surprising thing is to emit an error and exit if we don't have cached facts and none are specified on the command line. Nick's point about replacing vs overriding facts is still an issue but probably worth it's own ticket. Surely someone is relying on the current behavior of supplementing cached facts and would be surprised if they overwrote the cached ones. For example, if you want to introduce a new fact and want to see how that will change lookup behavior. Maybe a fact_merge strategy (overwrite vs merge) |