Jira (HI-619) Hiera return all keys (or keys matching pattern)

3 views
Skip to first unread message

Pat Riehecky (Jira)

unread,
Sep 11, 2020, 3:34:03 PM9/11/20
to puppe...@googlegroups.com
Pat Riehecky created an issue
 
Hiera / New Feature HI-619
Hiera return all keys (or keys matching pattern)
Issue Type: New Feature New Feature
Affects Versions: HI 3.5.0
Assignee: Unassigned
Components: CLI
Created: 2020/09/11 12:33 PM
Priority: Normal Normal
Reporter: Pat Riehecky

I'd like to have an option for hiera lookups to fetch all keys (or keys matching a pattern).

 

Example use case:

  • I'm looking to change my existing hierarchy by adding/removing a new element.  I'd like to validate that some nodes change and that others did not.  Dumping the return result and doing diffs from old/new would give me clear insight into the consequences of the change before going live.
  • I'm coming from an ENC (such as foreman) where I'm used to looking at the entire ENC config.  As I develop my hiera setup, I'd like to fetch the output for a node in a manner I'm familiar with.
  • A set of nodes is moving from my group to another group.  I've given them a list of puppet modules I'm using for these nodes, but I'd also like to provide the values each node is using so they can develop their configuration management.
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Henrik Lindberg (Jira)

unread,
Sep 11, 2020, 6:41:03 PM9/11/20
to puppe...@googlegroups.com
Henrik Lindberg commented on New Feature HI-619
 
Re: Hiera return all keys (or keys matching pattern)

Hiera is not designed to be able to enumerate all the keys. It can only answer with the value bound to a key (which it arrives at via a large set of rules).
You cannot do this by just looking at simple yaml/json files since it is a particular backend that reads those and provides the answer. You can also have backends that are backed by a database, or say LDAP. If you asked for "all keys" you would get a return that potentially consists of very large amounts of data.

Further, since lookups are done in a particular context (set of variable values) the result and indeed the set of available keys changes. Thus the answer to the question "give me all keys" is multidimensional - or would need to be constrained with the set of variables that the hiera key resolution depends on - something that is possible for some known variables like facts - but the full set of variables isn't declared anywhere - the backends can do pretty much what they want.

It difficult, but not impossible to add "enumeration of keys" to the hiera API, but it would need to have a mechanism for backends to opt in to support it, and also some mechanism for backends to respond with a signal that it would result in too much data. The implementation would be difficult since a backend in hiera 5 is just a simple function with a very clear purpose; too lookup a value. It would probably have to be an additional function that can do the enumeration which each hiera backend function provider would need to implement to support this feature.

Reply all
Reply to author
Forward
0 new messages