Issue #4549 has been updated by Markus Roberts.
I'm now doubting my snap diagnosis. The problem seems to be with autoloading
the functions from within a template. For example:
<pre>
notice sprintf('foo')
notice inline_template("<%= scope.methods.select{|meth| meth =~ /^function_/
}.sort.join('\n') %>")
</pre>
Produces:
<pre>
notice: Scope(Class[main]): foo
notice: Scope(Class[main]): function_alert
function_crit
function_debug
function_emerg
function_err
function_info
function_inline_template
function_notice
function_sprintf
function_warning
</pre>
(Note that sprintf is now "known" in the template).
----------------------------------------
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: 2.6.1rc2
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.