Ask Your Question

How can I merge hashes while using data bindings?

asked 2013-02-28 15:46:29 -0600

llowder gravatar image

I've got a define that is applied to all of my nodes - most of them use the exact same arguments, but a few nodes take the common set plus some additional arguments.

I've got a hash setup in my hierarchy for each node def, but this is a lot of duplicated data across several files.

At present, I have the hash as a parameter for each of my *_role classes.

Since the hiera lookup done by databindings just does a hiera() and not a hiera_array() or hiera_hash(), I can't take advantage of the merge feature of those ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-02-28 16:13:57 -0600

eric0 gravatar image

So there's two things here:

  • hash merging is coming in hiera 1.2, as part of Bug #16107
  • but even with that, it's true that in data bindings today you don't have the ability to control the behaviour of multiple matches across the hierarchy. Because they're automatic and behind-the-scenes you don't have a knob to turn to say what you want. This is something that the next major release of Hiera will address.

Sorry, wish there was a better answer. The good news is you're on the leading edge!

edit flag offensive delete link more


I can live with this - just means I have to live with duplicate data or non-databound lookups for a while, at least until I can come up with some sort ...(more)

llowder gravatar imagellowder ( 2013-02-28 16:18:10 -0600 )edit

answered 2013-03-01 10:54:44 -0600

EJSarge gravatar image

At class level you can do

class foobar(
  $myvar = hiera_hash('foobar::myvar')
) {

You then get the advantage of hiera's hashing to create $myvar.

edit flag offensive delete link more


Current version of hiera_hash() doesn't do deep merges (that's coming in hiera 1.2)

llowder gravatar imagellowder ( 2013-03-01 11:27:57 -0600 )edit

This example has a flaw: $foobar::myvar would be returned via data bindings rather than the parameter default, since data bindings take precedence over defaults.

cbarbour gravatar imagecbarbour ( 2015-04-30 01:59:46 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-02-28 15:46:29 -0600

Seen: 1,369 times

Last updated: Mar 01 '13