For an abandoned experiment awhile back I went to the trouble of mostly 
getting an external ruby script working that used Hiera 5 as a library. I 
don't know that you still want to do this, sounds like there may be other 
options per the conversation in the thread, but I'll post the following 
link as reference code in case it's useful. (Ferreting out which specific 
parts of the code relate to using Hiera 5 as a library is left as an 
exercise to the reader.)

https://github.com/reidmv/r10k_puppetfile_ref_lookup/blob/master/r10k_puppetfile_ref_lookup.rb

~Reid

On Monday, August 21, 2017 at 8:50:57 AM UTC-7, Craig Dunn wrote:
>
>
>
> > Maybe this is a bit overkill for your requirements, but this was
>> > actually one use case for Jerakia (http://jerakia.io).  Hiera 5 can use
>> > it as a backend from your Puppet implementation, and because it runs
>> > over an HTTP API other tools can easily hook into the same data
>> > lookups... for example there is now an Ansible lookup plugin that can
>> > pull the same data as Puppet.  It also has a client library written in
>> > Ruby which would hook into your script.
>>
>> So are you reaching out to Hiera 5 from Jerakia to do that and how are
>> you doing it?
>>
>
> The other way around, Hiera  reaches out to Jerakia.   Jerakia is 
> standalone but one way it can be used is as a backend to Hiera - it can 
> integrate with Puppet using a Hiera 5 backend that ships with the 
> crayfishx/jerakia Puppet module.  http://jerakia.io/integration/puppet
>
>  
>
>>
>> Are you as Hendrik suggested doing a compilation? What I saw as a big
>> difference is the whole context/scope that Hiera 5 is aware of, for
>> doing there lookups, which works for anything being called from puppet
>> code, but is kinda hard for an external query that must mimick that 
>> context.
>>
>
> No - if you are talking about looking up only data that is in your 
> hieradata path in a specific environment, it would be easy to get Jerakia 
> to read from the same file hierarchy, if you're using features inside of 
> Hiera / Puppet such as module level Hiera lookups and Puppet variable 
> interpolation, then this would, as Henrik said, require you to be in an 
> actual Puppet environment so it would be difficult to expose this in the 
> same way.  Your original post said you are on Hiera 3 though so it's highly 
> the data you have to date would be very easy to expose using Jerakia.   
>  Scope (eg: facts/variables..etc) shouldn't be an issue, you can hook up 
> Jerakia to pull the scope data from PuppetDB when you query data from 
> another tool.
>
>
> Craig
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/ea482bd6-7f9a-44e1-85c7-3f74e4546200%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to