Hi all,
I'm writing to the list after asking on IRC and getting no answers about an
issue I found.
It seems that there's a bug when trying to use Hiera with environments. When a
Hiera key is queried the environment is always set to 'production', no matter
which one the node is set in. I'm not using an ENC but declaring the
environment in puppet.conf on the agent side.
Looking into the issue here's what I found. In puppet/resource.rb:321 (in
Puppet::Resource#lookup_external_default_for) the scope object is used to
initialize a Puppet::DataBinding::Variables, and from then on
scope['environment'] will be used to access the environment. However this
never returns the value of the current node env, which is rightly returned
when using scope.environment.to_s.
I've started to look into Puppet::Parser::Scope and others to find where and
how the environment is initialized, but my Ruby skill are measly and I
couldn't get very far. As I needed this working quickly the workaround I did
was to patch Puppet::Parser::Scope#lookupvar to return 'environment.name.to_s'
when the requested key is 'environment' or '::environment'. Ugly, but it
works.
If this bug is not known or fixed I'll happily create a new report for it.
Cheers,
Grégory
PS: here's the ugly patch
--- parser/scope.rb.orig 2013-03-10 11:23:45.000000000 +0000
+++ parser/scope.rb 2013-03-08 14:25:38.000000000 +0000
@@ -261,7 +261,9 @@
options[:origin] = self unless options[:origin]
table = ephemeral?(name) ? @ephemeral.last : @symtable
- if name =~ /^(.*)::(.+)$/
+ if name == 'environment' or name == '::environment'
+ environment.name.to_s
+ elsif name =~ /^(.*)::(.+)$/
begin
qualified_scope($1).lookupvar($2, options.merge({:origin => nil}))
rescue RuntimeError => e
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" 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-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.