Title: Message Title
Francois Lafont updated an issue
Puppet / PUP-7882
lookup() function: set a kind of default value which is merged
Change By:
Francois Lafont
Hi,In brief, it will be convenient to be able to set a kind of default value in the {{lookup()}} function where this default value is merged with the "normal" value of the lookup. Now I try to give an example below to explain more precisely my idea.Suppose that I have a module {{mymod}} which has a parameter {{var}} which is a hash. Suppose that the default merge policy of this parameter {{mymod::var}} is {{deep}}. Now, I have a "role" class called {{myrole}} which inlcudes the class {{mymod}}. In this role, I need to set the {{var}} parameter to a specific value. So, for instance, in my hierarchy, I can set this in the file {{fqdn/$fqdn.yaml}}:{code:yaml}---mymod::var: { ... a specific value... }{code}With the 'deep' merge policy, I have *easily* and *exactly* the value I want for my role.But the problem is: this specific and final value of {{mymod::var}} is *intrinsic to my role*. I don't want the "hiera user" to be able to change this value in my role class because, if it is set to another value, my role has no meaning.So I would like to set this value directly in the body of my role class with something like that (the code is not currently valid of course because the feature doesn't exist yet):{code:puppet}class myrole { $options = {'default_merged_value' => { ... a specific value... }, } $specific_value_for_this_role = lookup('mymod::var', $options) class {'mymod':var => $specific_value_for_this_role, } }{code}Of course, this lookup option {{default_merged_value}} currently doesn't exist. The idea is:1. the {{lookup()}} makes its normal job of lookup...2. ... except that the {{default_merged_value}} is merged too in the lookup according to the current merge policy.I hope I'm clear...Maybe my request is not relevant (I don't think so but maybe I'm wrong), maybe it's not desirable, or maybe it is not easy to implement etc. Anyway, feel free to close this ticket if needed.Thanks for reading me. :) PS: edit typo
Add Comment