Skip to content
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 Hash Lookup Type #2

Closed
jjulien opened this issue Jul 10, 2014 · 10 comments
Closed

Support Hash Lookup Type #2

jjulien opened this issue Jul 10, 2014 · 10 comments
Milestone

Comments

@jjulien
Copy link
Owner

jjulien commented Jul 10, 2014

Currently only the priority lookup type is supported, we should add hash lookup types as well to allow recursive lookups through the hierarchy.

More info on lookup types can be found here
http://docs.puppetlabs.com/hiera/1/custom_backends.html#handling-lookup-types

@jjulien jjulien added this to the 0.2.0 milestone Jul 10, 2014
@calvn
Copy link
Contributor

calvn commented Dec 30, 2014

I am currently encountering this issue. If the class variable is a hash, hiera-regex does not look for it. Is there going to be a fix for this any time in the near future?

@jjulien
Copy link
Owner Author

jjulien commented Dec 31, 2014

@cleung2010, hiera-regex supports returning hash values, this ticket is for merging multiple hashed values from more than one matched key. If you are not getting any value returned at all there is likely something wrong with your hierarchy, regex, or this is a different bug.

Can you provide more details to reproduce this?

@calvn
Copy link
Contributor

calvn commented Jan 2, 2015

I am using a module called puppet-consul, and there is a class variable named config_hash: https://github.com/solarkennedy/puppet-consul/blob/master/manifests/init.pp

I tried using hiera-regex to fill a key-value pair in that hash like so:

---
 - 'localdc[0-9]{1}':
    consul::config_hash:
        datacenter: 'dc1'

However, the datacenter value does not seem to appear anywhere after the puppet run.

@calvn
Copy link
Contributor

calvn commented Jan 2, 2015

It might be also worth mentioning that I have config_hash defined in my default.pp (or site.pp). I only want certain KV pairs from configh_hash to be in hiera so it might be because it is, as you pointed out, not doing the merge.

@jjulien
Copy link
Owner Author

jjulien commented Jan 2, 2015

Hey @cleung2010 ,
If you are passing in config_hash then hiera will never look that up or attempt to merge it. Sounds like you don't need hiera hash merging but puppet hash merging. If you have the puppetlabs-stdlib module installed, it supports this. Your class would need to do something like this.

class consul($config_hash) {
  $merged_config = merge($config_hash, hiera('consul::config_hash'))
}

Since you don't control the consul class, you could probably just do the merge in site.pp instead.

class {'consul':
    config_hash => merge({'somekey' => 'somevalue'}, hiera('consul::config_hash'))
}

@calvn
Copy link
Contributor

calvn commented Jan 2, 2015

What if config_hash is in both common.yaml and hostname.regex, then would that be hiera hash merging? I am planning to remove config_hash from my site.pp and have the common KV values of config_hash in common.yaml

@jjulien
Copy link
Owner Author

jjulien commented Jan 2, 2015

@cleung2010 ,
Yes, that would be hiera hash merging and what this feature would enable. I do not have an ETA when it will be implemented.

@calvn
Copy link
Contributor

calvn commented Jan 2, 2015

Alright, mind if I fork to try to work on it and then send you a pull request?

@jjulien
Copy link
Owner Author

jjulien commented Jan 2, 2015

Not at all, thanks!

jjulien pushed a commit that referenced this issue Jan 6, 2015
@jjulien
Copy link
Owner Author

jjulien commented Jan 6, 2015

Fixed in #4

@jjulien jjulien closed this as completed Jan 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants