Issue #1427 has been updated by immerda. Status changed from Closed to Re-opened Assigned to changed from luke to jamtur01 Priority changed from Normal to High Target version set to 0.24.6
This whole commit introduces a new problem: if we have facter variables with a dot (.) in the name, the template wrapper will fail with the following error: <pre> Tue Sep 02 12:18:11 +0200 2008 Puppet (err): Failed to parse template munin/munin-node.conf.CentOS: [EMAIL PROTECTED]' is not allowed as an instance variable name at /srv/puppet/modules-development/munin/manifests/client.pp:68 on node foobar </pre> it is quite logical as ruby can't have variables with a dot in their name. the question is on which side we have to solve that? facter or puppet? ---------------------------------------- Refactor #1427: using missing_method for variable looking in TemplateWrapper allows trivial conflicts with built-in methods such as 'Kernel#fork' http://reductivelabs.com/redmine/issues/show/1427 Author: daniel Status: Re-opened Priority: High Assigned to: jamtur01 Category: Target version: 0.24.6 G'day. I have encountered what I think is a problem with template expansion as part of puppet, and wanted to confirm that my understanding is correct that this is a bug -- or identify how to work around it. So, I have created a class (with define) to represent a new configuration file that I am managing. One of the options in the configuration file is 'fork', for better or worse. So, using define I have, roughly, the following: test.pp: define foo ($fork = "yes") { file { "/tmp/output.txt": content => template("test.erb") } } node myhost { foo { "bar": } } test.erb: <%= fork.class %> <%= fork %> The output is 'Fixnum' and a PID on my machine, because ERB resolves the variable into the kernel method 'fork', forks the puppet process, and returns that PID to the parent. Ouch. The same can be demonstrated with 'object_id' in the ERB file, which is never resolved to an object_id variable no matter what. Sadly, according to the puppet documentation this should all work, but it doesn't. Worse, the root cause is the implementation of the template wrapper, which is all ... exciting: lib/puppet/parser/templatewrapper.rb:32 says: # Ruby treats variables like methods, so we can cheat here and # trap missing vars like they were missing methods. def method_missing(name, *args) Darn! This is never going to work if the ERB code is evaluated in an environment where Kernel is visible, and I don't believe Ruby allows us to create a new execution environment where that isn't the case. :? (We could, in theory, clone the default Binding, excise everything from it, then insert the ERB code and anything it depends on, including the Kernel object, at which point we face the same problem. Yay!) ---------------------------------------- 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://reductivelabs.com/redmine/my/account --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en -~----------~----~----~----~------~----~------~--~---
