I tried to use a Puppet variable named "$memory" and access it from a template, like this: $memory = 4711 file { "/tmp/test.txt": content => inline_template("memory = <%= memory %>\n"); } One would think that my file would contain "memory = 4711" after that, but instead the memory variable seems to hold a somewhat random number each time I run Puppet. On the two machines I have tried it (using the stand-alone puppet executable), I get values that are on the order of 100000. Other variable names work as expected, though. Why can''t I access $memory like other variables? From where does the value I do get come from? (My real use case was a define with a parameter named "memory", from where I called template(), but the above is a slightly shorter test case.) /Bellman --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Hi> Why can''t I access $memory like other variables? From where does the > value I do get come from?it looks like memory is somehow a special variable (dunno why), but if you don''t name your variable memory, it works. maybe report a bug report if nobody comes up with a reason why memory is special (it''s not a facter value!) and name your variable so long different. The following example works fine: $memory_foo = 123 notice("$memory_foo") file { "/tmp/test.txt": content => inline_template("memory = <%= memory_foo %>\n"); } cheers pete --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Schmitt
2009-Jul-01 08:26 UTC
[Puppet Users] Re: Variable named "memory" in templates
Peter Meier wrote:> Hi > >> Why can''t I access $memory like other variables? From where does the >> value I do get come from? > > it looks like memory is somehow a special variable (dunno why), but if > you don''t name your variable memory, it works.$memory is a fact containing amount of memory on the client. Regards, DavidS --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Hi>>> Why can''t I access $memory like other variables? From where does the >>> value I do get come from? >> >> it looks like memory is somehow a special variable (dunno why), but if >> you don''t name your variable memory, it works. > > $memory is a fact containing amount of memory on the client.hmm I thought that, but this one isn''t displayed with facter: # facter | grep memory memoryfree => 933.89 MB memorysize => 3.36 GB and if I do: # cat foo.pp notice("$memory") notice(inline_template("<%= memory %>")) # puppet foo.pp notice: Scope(Class[main]): notice: Scope(Class[main]): 36312 I don''t understand the difference. cheers pete --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Schmitt
2009-Jul-01 08:51 UTC
[Puppet Users] Re: Variable named "memory" in templates
Peter Meier wrote:> Hi > >>>> Why can''t I access $memory like other variables? From where does the >>>> value I do get come from? >>> it looks like memory is somehow a special variable (dunno why), but if >>> you don''t name your variable memory, it works. >> $memory is a fact containing amount of memory on the client. > > hmm I thought that, but this one isn''t displayed with facter: > > # facter | grep memory > memoryfree => 933.89 MB > memorysize => 3.36 GB > > and if I do: > > # cat foo.pp > notice("$memory") > notice(inline_template("<%= memory %>")) > > # puppet foo.pp > notice: Scope(Class[main]): > notice: Scope(Class[main]): 36312 > > I don''t understand the difference.d''oh. Perhaps this comes from ruby then? Regards, DavidS --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Thomas Bellman
2009-Jul-01 09:20 UTC
[Puppet Users] Re: Variable named "memory" in templates
David Schmitt wrote:> Peter Meier wrote:>> it looks like memory is somehow a special variable (dunno why), but if >> you don''t name your variable memory, it works.> $memory is a fact containing amount of memory on the client.No, it isn''t. At least not a fact that facter (version 1.5.5) reports. And $memory isn''t available in the manifests unless I set it explicitly. And even if it were, variable assignments in the manifests override facts. Compare the lines output from: node default { $memorysize = 4711 notice(inline_template("memorysize = <%= memorysize %>")) notice(inline_template("memory (template) = <%= memory %>")) notice("\$memory = <$memory>") notice("\$memoryfree = <$memoryfree>") } $memorysize *is* a fact from facter, and the above code tells me "memorysize = 4711" (while facter says it is "1.93 GB"). On the other hand, it says "$memory = <>", but "memory (template) = 105452" (or some similar, but varying, figure). I can of course work around it by doing ''$xmemory = $memory'' inside my definition (I don''t want to have a strange name as parameter to the definition), and accessing "xmemory" from the template, but it''s not particularly pretty... I''ll file this as a bug then, probably later today. /Bellman --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
> I''ll file this as a bug then, probably later today.yeah, good idea. cheers pete --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---