On Wednesday, October 8, 2014 8:44:56 AM UTC-5, Stack Kororā wrote:

I don't know why, but I am having a rough time trying to get hiera to
work. It seems to me that all the examples I see online are either absurdly
complex or so stupidly simple that they are absolutely useless. Either way
I have found the documentation for hiera completely lacking (it doesn't
help that there is a lot of bad information pertaining old puppet releases
that is no longer the correct way to do things...at least according to
other sources which may or may not be the correct way either...bleck...).
Of all the documentation/blogs/examples/ect I have been pouring over the
last 2 hours, not one has given me a useful hint at getting this working.

*deep breath in an attempt to control my frustration so I can
communicate on a somewhat intelligent level*


Keep breathing. Your frustration is coming through clearly -- and I don't
blame you for it -- but Hiera really does work, and there's not much more
to it than your research has already turned up.

OK. Lets start.


$ hiera hieratest::test clientcert=puppet.test.vm


# Hiera on the command line works. I must be making progress!!

$ sudo puppet agent -t

Info: Retrieving pluginfacts

Info: Retrieving plugin

Info: Caching catalog for puppet.test.vm

Info: Applying configuration version '1412771807'

Notice: /Stage[main]/Testhiera/File[/tmp/blah]/ensure: created

Notice: Finished catalog run in 0.03 seconds

What??? That is absolutely contrary to the documentation! It should have
created /tmp/yadda!

If the master had successfully looked up your datum then the result would
have been as you expected. The behavior you present is characteristic of
(and well documented for) the case where the automatic lookup fails,
leaving the master to fall back to the default value given in the class
definition. The problem is not in your Puppet manifests, and your CLI
tests demonstrate that it is not in your data themselves, but those are not
the only possibilities.

I am looking at the official docs right now on using a hiera variable with
a default variable and I don't see how my example is any different in the
slightest! Blah should have only been used as a default if the host wasn't
found. Clearly either puppet can't find hiera and used default, or it
simply ignored the hiera data.

Fine. We will take out the default blah and force it to use something
from hiera.

$ rm /tmp/blah

$ cat modules/testhiera/manifests/init.pp

class testhiera ( ) {

file { "/tmp/$test" : ensure => present}


$ sudo puppet agent -t

Info: Retrieving pluginfacts

Info: Retrieving plugin

Info: Caching catalog for puppet.test.vm

Info: Applying configuration version '1412773578'

Notice: Finished catalog run in 0.04 seconds

What? No blah, no yadda, nothing! I don't even get an error!!

How's hiera involved in that? You now have $test as an uninitialized local
variable (no longer a class parameter). It expands to nothing when you
interpolate it into your filename, so you're managing File["/tmp/"], which
is equivalent to File["/tmp"]. That file (directory) already exists, and
that's all you ask Puppet to ensure, so Puppet does nothing.

OK. OK. Fine. Maybe it doesn't like something in hiera. I will give hiera
a default.

Unless you change the class back, you've already run off the rails here.
You have no hiera lookup involved any more.


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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/609b4371-30b3-41fd-82c0-02845d0550a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 16 | next ›
Discussion Overview
grouppuppet-users @
postedOct 8, '14 at 1:44p
activeOct 14, '14 at 7:50a



site design / logo © 2022 Grokbase