The existing hiera interpolation function alias is problematic to use. By adding a key alias in lookup_options for an original-key a lookup should take that alias-key and use it to lookup instead of the given original-key.
Details:
The implementation must guard against circular aliases
There is an option wrt handling of the other lookup_options:
Use the options for original-key and ignore those in alias-key
ignore the options for original-key and use those for the alias-key
merge the options with original-key at higher t
If an alias-key is in turn aliased, the process recurses
Option 3 allows for just specifying alias and getting the rest of the options from the aliased key.
We can also add advanced features:
If the alias-key is an array, the entries in that array are used as aliased lookups and the result is an array with those values.
If the alias-key is a hash, the keys are used as keys in the resulting hash where values are the looked up keys
A simpler, and perhaps more straight forward solution that was proposed in PUP-8341, is to introduce an additional interpolation function. This has already been done in the Go version of Hiera. The function is called `strict_alias` and behaves like `alias` with the exception that a not found is propagated instead of translated into an empty string.
Thomas Hallgren That is solving PUP-8341, a completely different problem than this ticket (what is described above would also benefit from having some kind of "strict" option). I think PUP-8341 should be reopened for the purpose of adding strict_alias interpolation function.
This ticket is about having a more powerful mechanism for aliasing than what is currently possible with the hiera interpolation functions.
Not sure why that is. The only thing that the current alias doesn't, is to propagate the "not-found" condition. It preserves the type and it guards against recursion. Perhaps I'm missing something but besides the "advanced features" (which I personally think we should avoid), I don't see more value added here.