On 30/08/17 09:32, Justin DynamicD wrote:
> I finally was able to solve this issue on my own, so posting for others
> who may have been lost:
>
> the hiera () syntax is _very_ sensitive, even more-so than runnning
> hiera and the command prompt. So while:
>
> hiera <server>.Services would call back all the services on a node from
> the commanline,
> hiera ($::hostname.Services) would fail, and instead you have to settle
> for the "base" match of simply hiera(<server>). once you have that base
> array you can then call out hashes from there.
>
> There may be a way to abuse ruby to get the info a bit more efficiently,
> but that's out of scope of this question.
>
From Puppet 4.10 and forward you have hiera 5 available. The earlier
hiera 3 and 4 formats and APIs have been deprecated in favor of hiera 5,
and the lookup CLI is favoured over the hiera CLI, and the lookup
function favoured over the hiera, hiera_array, hiera_has (etc) functions.
With hiera 5 a "hiera backend" is simply a function implemented using
puppet 4.x function API which makes backend writing much simpler.
The lookup function is more powerful than the older hiera calls, and you
can do things like 'dot style dig' into data structures directly in the
lookup.
Lots of information in the documentation for hiera 5. Yu may want to
start reading here:
https://docs.puppet.com/puppet/5.1/hiera_intro.html#whats-the-deal-with-hiera-5
Best,
- henrik
> ensure=> present,
> content =>inline_template($myresult),
> }
>
> }
> |
>
>
>
> As you can see this does very little other than perform a hiera
> lookup (for hostname) and then dump the output into a file so I
> can see what it's gathering.
>
> The file is always empty.
>
> I've tried a few different variations to attempt to get data
> out, but I'm not certain of how. What I'd like to emulate is
> simply:
>
> consul catalog services -node=<nodename>
>
> This simple command returns all the services registered to a
> specified node as an array. That's basically all I'm trying to
> get back from consul via hiera so I can then use simple If
> "application" in $getdata".
>
> Anyone have any insight on what setting I might be missing?
> Simple syntax issue? consul trick?
>
>
> --
> 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
puppet-users...@googlegroups.com
> <mailto:
puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/puppet-users/eb1a7ae9-a75e-4acc-82a4-41eb05e103bf%40googlegroups.com
> <
https://groups.google.com/d/msgid/puppet-users/eb1a7ae9-a75e-4acc-82a4-41eb05e103bf%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit
https://groups.google.com/d/optout.
--
Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/