Issue #21198 has been updated by Robert Frank.
I agree, it should be re-factored. Duplicating code is never a good idea. As a
quick fix, it might be possible to avoid duplicating the code by using
Hiera::Scope within Puppet::DataBinding, for example:
<pre>
--- data_binding.rb.org 2013-06-11 10:39:18.501246184 +0100
+++ data_binding.rb 2013-06-13 11:25:28.313886430 +0100
@@ -18,11 +18,11 @@
FAKE_CATALOG = Struct.new(:classes).new([].freeze).freeze
def initialize(variable_bindings)
- @variable_bindings = variable_bindings
+ @hiera_scope = ::Hiera::Scope.new(variable_bindings)
end
def [](name)
- @variable_bindings[name]
+ @hiera_scope[name]
end
def resource
</pre>
I don't know if this has any unwanted side effects though.
----------------------------------------
Bug #21198: hiera calling_module / calling_class not set for automatic
parameter lookups
https://projects.puppetlabs.com/issues/21198#change-92894
* Author: Robert Frank
* Status: Accepted
* Priority: Normal
* Assignee: Andrew Parker
* Category:
* Target version:
* Affected Puppet version: 3.0.0
* Keywords:
* Branch:
----------------------------------------
The automatic parameter lookup uses a different scope (Puppet::DataBinding)
than the explicit lookup with the hiera function (Hiera::Scope). The
calling_module and calling_class variables are generated in Hiera::Scope and
therefore are not available when automatic parameter lookup is used. This
breaks hiera configurations that make use of those variables for lookups.
Including the following class in a node definition on a puppet master
<pre>
class test($myopt = 'default') {
notify { "auto myopt: ${myopt}": }
$myvar = hiera('test::myopt', $myopt)
notify { "hiera myopt: ${myvar}": }
}
</pre>
with a hiera configuration that uses
<pre>
- %{calling_module}
- common
</pre>
and different configuration values for test::myopt in test.yaml and common.yaml
prints the value defined in test.yaml for the explicit lookup and the value
defined in common.yaml for the automatic lookup.
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.