On Friday, September 18, 2015 at 4:36:32 PM UTC-5, Joao Morais wrote:
>
>
> Hello list. I am using the hiera() lookup function in order to query 
> some few attributes from a http backend. Something like this: 
>
>     common.yaml 
>     --- 
>     ... 
>     class::attr: "%{hiera('other::attr')}" 
>
> This works very well if other::attr is defined, but an empty string is 
> returned in the lookup above if the other::attr isn't found. The hiera() 
> function on the manifest fails the compilation if I do the same query, 
> which is what I'd expect from the lookup above. 
>


You have a misconception, albeit an understandable one: the Puppet function 
hiera() is not the same as the Hiera interpolation function of the same 
name. The two perform very similar work, but there is no inherent reason to 
suppose that they must operate identically.  Their interfaces are not even 
quite the same (at least as far as their documentation says), for the 
Puppet function accepts up to three arguments, whereas the Hiera function 
documents only one.

 

>
> Is there a way to enforce the declaration of the other::attr when using 
> hiera() lookup function inside the hieradata? 
>
>

No such mechanism is documented.  You could file a feature request, but 
inasmuch as there may be sites that knowingly or unknowingly depend on the 
current behavior, I judge it unlikely that such a feature request would be 
accepted.  Perhaps PL would be more receptive if you structured the request 
as an extension rather than as a behavior change -- an alternative lookup 
function, for example, or an additional argument to the existing one.

For now, perhaps you could instead put a throwaway call to the Puppet 
hiera() function in an appropriate manifest, so as to force compilation 
failure *there* in the event that the wanted key is not defined.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/5a3eb299-ad99-4751-b073-dda600f3b129%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to