:merge_behavior: deeper and hiera_hash

795 views
Skip to first unread message

William Leese

unread,
Oct 29, 2013, 10:21:05 PM10/29/13
to puppet...@googlegroups.com
Hi,

To my surprise hashes passed to class parameters pulled from hiera with :merge_behavior: deeper, are not merged "as expected", where as hiera_hash does work "as expected".

Or to rephrase: they behave differently, despite merge_behavior being set.

I found a snippet documenting this here:

Might make sense to make these things allot more apparent by listing the caveats and known issues at the top of the documentation and in release notes.

That said, Hiera is great and I'm looking forward to future improvements. 

jcbollinger

unread,
Oct 30, 2013, 9:08:14 AM10/30/13
to puppet...@googlegroups.com


On Tuesday, October 29, 2013 9:21:05 PM UTC-5, William Leese wrote:
Hi,

To my surprise hashes passed to class parameters pulled from hiera with :merge_behavior: deeper, are not merged "as expected", where as hiera_hash does work "as expected".

Or to rephrase: they behave differently, despite merge_behavior being set.



Per the docs, the :merge_behavior setting affects how hashes are merged in a "hash merge lookup".  Not every hiera lookup is a hash merge lookup, and whether a query is of that kind does not depend on the type of the data retrieved.  A standard hiera lookup, such as is performed by the ordinary hiera() function, simply returns the highest-priority datum it finds in the data hierarchy.  This is what is used for automated class parameter binding.  A hash merge lookup, on the other hand, is what you get from the hiera_hash() function.



John

William Leese

unread,
Oct 30, 2013, 10:07:28 PM10/30/13
to puppet...@googlegroups.com

On Wednesday, October 30, 2013 10:08:14 PM UTC+9, jcbollinger wrote:
Per the docs, the :merge_behavior setting affects how hashes are merged in a "hash merge lookup".  Not every hiera lookup is a hash merge lookup, and whether a query is of that kind does not depend on the type of the data retrieved.  A standard hiera lookup, such as is performed by the ordinary hiera() function, simply returns the highest-priority datum it finds in the data hierarchy. This is what is used for automated class parameter binding.  A hash merge lookup, on the other hand, is what you get from the hiera_hash() function.

Makes sense. 

I think that the confusion stems from using on hiera_include's array merge lookup, seeing your class arrays being merged nicely and assuming such behaviour extends to class parameter binding. I understand the reasons maintaining priority lookup for class parameters though. 
Reply all
Reply to author
Forward
0 new messages