puppet functions in EPP templates?

54 views
Skip to first unread message

Christopher Wood

unread,
Jul 26, 2017, 9:50:24 AM7/26/17
to puppet...@googlegroups.com
Would somebody mind passing a spare clue regarding the correct syntax?

I already know this works in an erb template:

<%= scope.call_function('test1::test1', ['input one!!']) %>

However this fails in an epp template:

<%= test1::test1('input two!!') %>

Unfortunately, that's about as far as I got using "puppet apply".

My stub test module (with the busted epp part commented out):

https://gist.github.com/christopherwood/b7e3b4c60a60a8088a2a42f1242df2d9

And the result with the epp part uncommented:

$ puppet apply --modulepath . test1.pp
Error: Evaluation Error: Error while evaluating a Function Call, Failed to parse template test1/two.epp:
Filepath: /var/tmp/t1/test1/templates/two.epp
Line: 1
Detail: undefined local variable or method `test1' for #<Puppet::Parser::TemplateWrapper:0x000000037e4a20>
at /var/tmp/t1/test1/manifests/init.pp:6:16 on node cwl.me.com

I read these but couldn't find an obvious example, if somebody would like to point one out.

https://docs.puppet.com/puppet/4.10/lang_expressions.html
https://docs.puppet.com/puppet/4.10/lang_functions.html
https://docs.puppet.com/puppet/4.10/lang_template_epp.html

As far as use case, I wanted to see if it would work for potential upcoming module notions since parameterizable epp makes some things easier.

Christopher Wood

unread,
Jul 26, 2017, 10:05:50 AM7/26/17
to puppet...@googlegroups.com
And sometimes it turns out the answer is obvious in retrospect once one's error has been posted up in public. I was doing:

file { '/tmp/tt2':
content => template('test1/two.epp'),
}

When I actually invoke an epp template like I should, it works.

file { '/tmp/tt2':
content => epp('test1/two.epp'),
}

We'll please attribute this to an unusual moment of dimness.
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20170726135011.aus2qeaqn7egtvns%40iniquitous.heresiarch.ca.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages