Module hiera, lookup() and deep merge

41 views
Skip to first unread message

Nelo-Thara Wallus

unread,
Nov 21, 2016, 5:28:50 PM11/21/16
to puppet...@googlegroups.com
Hello everybody,

I'm currently writing an openssh module in puppet 4 and wanted to
utilize the module hiera to define the defaults instead of supplying
them directly.

E.g. the openssh::server resource sets the parameter $options to the deep
merged value of a deep-merge lookup of `openssh::server` and
`openssh::server::$ident`.

Now, when supplying the defaults via a module hiera those defaults would
always be merged with what the user set in their environment/classic
hiera - which isn't exactly the goal of defaults.

My first idea was to use a function which looks up the given values from
above and then merges `openssh::server::default` into it to fill any
unset values with the default. However I'd make that as an additional
module with a generalized version to use with other modules, which in
turn would create additional dependencies.

Maybe I'm overthinking this, but I'd love to hear if someone has
a solution for this.

Thanks all,
Cheers,
Nelo

--
/"\ ASCII Ribbon Campaign
\ / - against HTML emails
X - against proprietory attachments
/ \ http://en.wikipedia.org/wiki/ASCII_Ribbon_Campaign

Francois Lafont

unread,
Nov 21, 2016, 6:22:31 PM11/21/16
to puppet...@googlegroups.com
Hi,

On 11/21/2016 09:59 PM, Nelo-Thara Wallus wrote:

> I'm currently writing an openssh module in puppet 4 and wanted to
> utilize the module hiera to define the defaults instead of supplying
> them directly.

I suppose it's not "module hiera" but "provider hiera". ;)

> Now, when supplying the defaults via a module hiera those defaults would
> always be merged with what the user set in their environment/classic
> hiera

Not necessarily.

You can set the default merge policy for specific keys of your module with
the magic key "lookup_options". You can have more details here:

https://www.devco.net/archives/2016/02/03/puppet-4-data-lookup-strategies.php

It's a good news, isn't it? ;)

François Lafont
Reply all
Reply to author
Forward
0 new messages