-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support array and hash merging from multiple matched keys #4
Conversation
@cleung2010 , Thanks for the pull request. I made a few modifications and condensed this into a single commit. |
Did you test the |
Confirmed it's working! Weird, I tried using that same case |
Yes, resolution_type works. The problem with using is_a?(Array) is that is ALWAYS merges the array, and it only merges arrays too. So it wouldn't merge 3 string values into an array. You have to tell hiera if you want it to merge your lookup. That might be why resolution_type wasn't working. Puppet's automatic parameter lookup only support priority. https://docs.puppetlabs.com/hiera/1/puppet.html#limitations. If you want to retrieve the value as an array or hash merge you need to call the specific hiera lookup function to do this. |
I wasn't merging in puppet at all, I simply had two hashes with the same name, say one in Basically I wanted |
After a more thorough test on v0.3.0, using ---
- '[a-z]+dc[0-9]{1}':
consul::config_hash:
server: true
- 'localdc[0-9]{1}':
consul::config_hash:
datacenter: 'dc1' The above example would fail to merge consul::config_hash |
How are you looking up the parameter? You need to use hiera_hash('consul::config_hash'). |
I am not using that, but still getting a hash back that just has the unmerged values from the top matched hash (i.e. I tried printing |
Hiera is not suppose to merge a value just because it has a like data type, which is what the The regular hiera function passes in priority The automatic lookup feature of puppet passes in Which hiera defaults to You need to use the |
I see, thanks for clearing things up. Is there a link for an example of using hiera_hash with JSON or regex backend? So this would mean that modules would have to explicitly support hiera by modifying their modules to use hiera_hash? |
Correct, any module wanting to do a hash_merge will have to explicitly do so. All of the hiera functions take the same arguments, it's how they do the lookup (ie. merge hash, merge array, priority) that is different. |
No description provided.