The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #2379

Puppet::Util should not be included in Puppet::Parser::TemplateWrapper

Added by Thomas Bellman almost 5 years ago. Updated almost 5 years ago.

Status:AcceptedStart date:07/01/2009
Priority:LowDue date:
Assignee:-% Done:

0%

Category:functions
Target version:-
Affected Puppet version:0.24.8 Branch:
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket may be automatically exported to the PUP project on JIRA using the button below:


Description

If I have a variable named $memory in my manifests, I can’t access that from templates. Instead I get some semi-random number.

node default {
    $memory = 4711
    notice(inline_template("memory = <%= memory %>"))
}

This gives me the output

notice: Scope(Node[default]): memory = 105436

but the exact number varies between runs. It seems to stay at approximately 100'000, though.

Other variable names work fine. If I rename it to $xmemory, it works as expected. It isn’t a clash with facter facts either, because facter doesn’t report any fact named “memory”. Even if it were, assignments inside the manifests override facts; if I use $memorysize in the example above (which is a fact), I get 4711 as expected.

I tried to add some instrumentation to parser/templatewrapper.rb, but couldn’t find find anything interresting. method_missing() isn’t called for “memory”, and result() doesn’t call instance_variable_set() with “memory”. Likewise, binding.memory doesn’t exist. But my Ruby knowledge is fairly rudimentary, so take that bit of debugging with a grain of salt.

This happens with at least 0.24.8 on CentOS 5.3, and a Git snapshot of 0.25 (769c8aa71e5b4855662314f13b1197853cdc843a) on Fedora 9.

History

#1 Updated by James Turnbull almost 5 years ago

  • Status changed from Unreviewed to Needs More Information
  • Assignee set to Luke Kanies

Any ideas? Memory isn’t a reserved word or a fact?

#2 Updated by Luke Kanies almost 5 years ago

  • Subject changed from Variable named "memory" is clobbered in templates to Puppet::Util should not be included in Puppet::Parser::TemplateWrapper
  • Status changed from Needs More Information to Accepted
  • Assignee deleted (Luke Kanies)
  • Priority changed from Normal to Low

This is because Puppet::Util is included in TemplateWrapper. This is probably unnecessary and could almost definitely be fixed relatively easily.

In the meantime, you can use ‘@memory’ as a trivial workaround.

Also available in: Atom PDF