Issue #4549 has been updated by Peter Meier.
Markus Roberts wrote: > Two more observations: 1) this existed in 0.25.x as well, and thus is not new > breakage yeah, I'm now on running on 2.6.1.rc2++ and this is something completely new I wanted to try. So I couldn't tell whether it have already been broken before or it already worked. But it looks like it have been broken the other mail I linked notes. > 2) you can hack around it by forcing the function to load (not recommend, but > noted), e.g.: > > [...] > > What was the use case you had in mind? I have a couple of templates, which have their own stuff, but share also a lot of snippets. Furthermore, there are a like a dozen of such templates and it would get too complicated and even more messy than they already are to put them all together into one big template. Therefore I thought about putting the shared template code in snippets, so I define at least the shared parts only once. Therefore, I'd like to use the template function in templates. This is the main use case currently for me. And as I would use the template function within the template function it would already been there, so that works anyway. I have to admit that I didn't try to use the template function in a template, which should work according to your discovery. But what I did, was trying to use @fqdn_rand@ in the inline template as this was a quick test for me to see if I can really call functions that way and this didn't work. So therefore I looked what kind of functions are around and they were all missing :/. So in my opinion we have now a workaround, however it might be still good to have it simply working, because only documenting that workaround is imho rather ugly. Hence, I would propose to put another branch into the already existing @method_missing@ of the scope object. We would try to load the custom function there if the call looked like @^function_@ and if that works we would delegate the call to the newly added function. This would only be a problem for the first time and all subsequent message sends to that function wouldn't anymore land in @method_miss...@. ---------------------------------------- Bug #4549: not all puppet functions are available in the template scope http://projects.puppetlabs.com/issues/4549 Author: Peter Meier Status: Accepted Priority: Normal Assigned to: Category: Target version: queued Affected version: 0.25.5 Keywords: Branch: I was looking for a way to call puppet function in templates (for example to evaluate a template in a template). According to http://serverfault.com/questions/34642/call-puppet-function-from-puppet-template it looks like this is possible. However it does not seem to work for all functions: <pre> # cat foo.pp $a = inline_template("<%= scope.methods.select{|meth| meth =~ /^function_/ }.sort.join('\n') %>") notice $a # puppet foo.pp notice: Scope(Class[main]): function_alert function_crit function_debug function_emerg function_err function_info function_inline_template function_notice function_warning # </pre> There was also a report about that on the users list with no answer: http://groups.google.com/group/puppet-users/browse_thread/thread/59a7ee977b26fc3d In general we can ask: Is it the idea that puppet functions are available in templates? If no, why is the inline_template function available? Besides that I think functions in general should be available. If yes, where are the missing functions and how can we call them? Looking at the code doesn't reveal how inline_teplate might be added in a special way to the scope, also it seems that the function creation code should register the functions and at least for the tests they seem to be registered. -- 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 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.
