How to Read New Files Dynamically with Hiera?

85 views
Skip to first unread message

o...@soluto.com

unread,
Apr 14, 2016, 12:32:24 PM4/14/16
to Puppet Users
 Hi,
We need to manage many keys in Hiera. Since many people should be able to edit the keys and in order to avoid a complete mess I was thinking to work with many different files. The problem is that I don't know how to make Hiera read from new files. I don't want to add each file to the hierarchy explicitly.
Optimally I would add something like that
/etc/puppetlabs/code/enironments/%{::environment}/hieradata/delegated/*

and Hiera will just read from all files that are under the
delegated

folder. I wasn't able to find how to achieve my goal.
What is the correct approach here?

Thanks

Thomas Müller

unread,
Apr 14, 2016, 2:34:06 PM4/14/16
to Puppet Users


Am Donnerstag, 14. April 2016 18:32:24 UTC+2 schrieb o...@soluto.com:
 Hi,
We need to manage many keys in Hiera. Since many people should be able to edit the keys and in order to avoid a complete mess I was thinking to work with many different files. The problem is that I don't know how to make Hiera read from new files. I don't want to add each file to the hierarchy explicitly.
Optimally I would add something like that
/etc/puppetlabs/code/enironments/%{::environment}/hieradata/delegated/*


IMHO this is not possible. 

maybe another backend might be of interest for you:


or you create a file-change-listener (for example with inotify-tools https://github.com/rvoicilas/inotify-tools) which monitors delegated/* to dynamically recreate delegated.yaml. There is even the fancy option to call a systemd job on every change in a directory IMHO (not used myself yet).


- Thomas

Christopher Wood

unread,
Apr 14, 2016, 4:26:09 PM4/14/16
to puppet...@googlegroups.com
This will be easier for you if you store your hiera data in revision control (say git) and have the puppetmasters sync it. That way it will be obvious who added what line and when.

> --
> 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 [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/26984a85-bd19-4c86-acae-0b0dd5364125%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/26984a85-bd19-4c86-acae-0b0dd5364125%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

Craig Dunn

unread,
Apr 15, 2016, 8:03:39 AM4/15/16
to puppet...@googlegroups.com

On Thu, Apr 14, 2016 at 4:34 PM, <o...@soluto.com> wrote:
 Hi,
We need to manage many keys in Hiera. Since many people should be able to edit the keys and in order to avoid a complete mess I was thinking to work with many different files. The problem is that I don't know how to make Hiera read from new files. I don't want to add each file to the hierarchy explicitly.
Optimally I would add something like that
/etc/puppetlabs/code/enironments/%{::environment}/hieradata/delegated/*

and Hiera will just read from all files that are under the
delegated


You could use Jerakia to do this (it can also be configured as a regular hiera backend).  It supports fragments so if your hierarchy contains "/delegated" then the presence of a directory called "delegated.d" will automatically get checked and if present any files within it are concatenated together along with delegated.yaml and returned as one YAML document.....  see the "Fragments" documentation in http://jerakia.io/datasources/file/



o...@soluto.com

unread,
Apr 18, 2016, 7:45:58 AM4/18/16
to Puppet Users
I'm using git, but still, a single file is too messy. I will take a look at Jerakia.

R.I.Pienaar

unread,
Apr 18, 2016, 8:19:24 AM4/18/16
to puppet-users


----- Original Message -----
> From: o...@soluto.com
> To: "puppet-users" <puppet...@googlegroups.com>
> Sent: Monday, 18 April, 2016 13:45:58
> Subject: Re: [Puppet Users] How to Read New Files Dynamically with Hiera?

> I'm using git, but still, a single file is too messy. I will take a look at
> Jerakia.
>

there is a HOCON backend for hiera https://github.com/cprice404/hiera-hocon
and HOCON supports including files into others, not sure if this will let
you do what you want but it's an option for staying with Hiera
> --
> 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/2e420308-dc27-403e-81af-cd1ef23649ee%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages