Jira (PUP-7362) Improve handling of facts and $trusted in CLI apps for Puppet lookup

16 views
Skip to first unread message

Henrik Lindberg (JIRA)

unread,
Jan 10, 2019, 10:01:05 AM1/10/19
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
 
Puppet / Improvement PUP-7362
Improve handling of facts and $trusted in CLI apps for Puppet lookup
Change By: Henrik Lindberg
Issue Type: Bug Improvement
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (Jira)

unread,
Apr 16, 2020, 8:02:04 PM4/16/20
to puppe...@googlegroups.com
Josh Cooper commented on Improvement PUP-7362
 
Re: Improve handling of facts and $trusted in CLI apps for Puppet lookup

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)

This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Apr 22, 2020, 8:23:03 PM4/22/20
to puppe...@googlegroups.com
Josh Cooper commented on Improvement PUP-7362

After discussing with Nick Walker, we decided that if the facts terminus returns nil and no facts were specified on the command line, then we should error early instead of trying to lookup the key.

Josh Cooper (Jira)

unread,
Apr 22, 2020, 8:26:02 PM4/22/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Acceptance Criteria: If the {{ \ - \ -node}} option is specified and the node has never submitted facts, then trying to lookup a key for that node should fail fast with a message that facts can be supplied/overridden using the {{--facts}} option.

This is not an issue when the {{--node}} option is omitted, because in that case we use facter to collect facts.

Josh Cooper (Jira)

unread,
Apr 22, 2020, 8:26:02 PM4/22/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Acceptance Criteria: If the {{--node}} option is specified and the node has never submitted facts, then trying to lookup a key for that node should fail fast with a message that facts can be supplied/overridden using the {{--facts}} option.


This is not an issue when the {{--node}} option is omitted, because in that case we use facter to collect facts.

Josh Cooper (Jira)

unread,
Apr 22, 2020, 8:26:03 PM4/22/20
to puppe...@googlegroups.com
Josh Cooper assigned an issue to Unassigned
Change By: Josh Cooper
Assignee: Lindsey Smith

Josh Cooper (Jira)

unread,
Apr 22, 2020, 8:27:02 PM4/22/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Apr 22, 2020, 8:27:03 PM4/22/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Apr 22, 2020, 8:27:03 PM4/22/20
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages