Exit Puppet when a custom Hiera backend is not found

41 views
Skip to first unread message

Vaidik Kapoor

unread,
Oct 1, 2014, 1:29:43 PM10/1/14
to puppet...@googlegroups.com

Hi Guys,

I am using masterless Puppet. And My situation is that I am using a custom Hiera backend called hiera-regex. The process of using it is that you have to have hiera-regex installed on your target machine.

If sometime for some reason, hiera-regex is not installed, hiera still looks up for the key in hierarchy and starts using that key which it was not suppose to use in the presence of hiera-regex. Ideally, I would want Puppet to exit when it does not find hiera-regex backend installed. But as of now, Puppet only prints a notice() which can be easily missed and can leave your node in an unwanted state.

Is it possible to somehow configure Puppet/hiera for masterless setup to not continue at all if hiera is configured to use a custom backend and that backend is not installed?

Here is my hiera.yaml file:

---
:backends:
    - regex  # this is the custom backend (hiera-regex)
    - yaml

:regex:
    :datadir: /etc/puppet/hiera

:yaml:
    :datadir: /etc/puppet/hiera

:hierarchy:
    - "%{fqdn}"
    - base

Expecting some help on this. I have posted the same question on stackoverflow as well: http://stackoverflow.com/questions/26133604/exit-puppet-when-hiera-backend-is-not-found

Thanks,
Vaidik Kapoor
vaidikkapoor.info

Nan Liu

unread,
Oct 1, 2014, 3:58:36 PM10/1/14
to puppet...@googlegroups.com
Perform a data lookup for a non relevant key that only exists in the hiera-regex backend or fail the catalog.

if !hiera('hiera::regex') { fail('hiera-regex backend does not appear to be loaded') }

Nan

Vaidik Kapoor

unread,
Oct 2, 2014, 2:45:36 AM10/2/14
to puppet-users
Thanks for the suggestion. Looking for a non-existent key sounds like a decent work around for now. Thanks a lot for the help! :)

Vaidik Kapoor
vaidikkapoor.info

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CACqVBqCf%2BnF9wFp-5Q4rWMZ%2B5wHNjxeLbdpxr_G%2BMRTkUMTM8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages