On Saturday, April 28, 2018 at 6:21:12 AM UTC-5, du wrote:
 

> Of course I always have alternatives like replacing all hiera_hash() 
> functions in my manifests with lookup() with correct options however this 
> is a fair bit of work and I wanted to make sure first I absolutely cannot 
> achieve this by tweaking Hiera options.
>


Coming back to that comment, I think you may have some wrong expectations 
here.  If you continue to use the hiera_hash() function 
<https://puppet.com/docs/puppet/5.5/function.html#hierahash> then nothing 
should change for you.  It is still documented to honor the :merge_behavior 
key, and it is also documented to ignore the lookup_options, and to only 
lookup data from one hierarchy (not three, as Hiera 5 does).  If you 
observe different behavior then you should file a bug report.  But that 
means *not* moving to Hiera 5 API-wise.  Moreover, unless you also stick to 
a single, global hierarchy overall, Hiera 3 style, you will be setting 
yourself up for problems and confusion.  Moving to Hiera 5 means moving to 
lookup().

If it were me, I'd just bite the bullet and switch over.  It may be a bit 
of a pain to convert hiera(), hiera_hash(), and hiera_array() calls to 
lookup() calls, but inasmuch as each of these implies a different merge 
strategy, it should be possible to automate the changes.  Moreover, in so 
doing, you can set up pretty good emulation of the Hiera 3 hash-merge 
behavior for those lookup() calls that want to participate.  In particular, 
consider doing this at top scope in your site manifest:

$hash_merge_behavior = lookup(':merge_behavior', String, 'unique', 'hash')

... and then converting each

# original
$my_hash = hiera_hash('key', { ... })

to 

# updated
$my_hash = lookup('key', Hash, $::hash_merge_behavior, {...})

.  The hiera() and hiera_array() calls can be converted in a similar 
manner. The one thing to look out for is any three-parameter hiera*() 
calls, for, to the best of my knowledge, lookup() does not offer any 
hierarchy-modulation behavior corresponding to what the hiera* functions do 
with that third parameter.


John

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/c054422b-53b0-4007-a9ff-1839bae84a04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to