Issue #5587 has been reported by donavan m.
----------------------------------------
Bug #5587: autoloading function fails inside of template
https://projects.puppetlabs.com/issues/5587
Author: donavan m
Status: Unreviewed
Priority: Normal
Assignee:
Category:
Target version:
Affected Puppet version: 2.6.4
Keywords:
Branch:
It appears that trying to autoload puppet functions inside of a template hangs
the puppet master. I've only tested in webrick but eventually it will fail with
something like `err: Failed to parse template test.erb: undefined method
'function_fqdn_rand' for #<Puppet::Parser::Scope:0x2b38f2ec80c8> at
/tmp/puppet/site.pp:43`.
A quick example template & manifest that should fail:
<pre>
<%# test.erb %>
<% value = scope.function_fqdn_rand(['10']) -%>
<%= value.to_s %>
</pre>
<pre>
# fail.pp
$value = template('test.erb')
notice($value)
</pre>
There are at least two workaround to resolve the function block:<br>
Call the function in manifest first:
<pre>
# success.pp
$junk = fqdn_rand('10')
$value = template('test.erb')
notice($value)
</pre>
Instantiate it manually in the template:
<pre>
<%# test.erb %>
<% Puppet::Parser::Functions.function('fqdn_rand') -%>
<% value = scope.function_fqdn_rand(['10']) -%>
<%= value.to_s %>
</pre>
This appears to be related to #4549. I tested this on 2.6.4, but from the
comment in #4549 I'd suspect it applies to previous versions as well.
I'd also note that I used fqdn_rand() above for clarity. I actually ran in to
this when I was trying to get a custom function to work. The above work arounds
seem to work for custom functions as well as the core.
--
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.