epp conditionals not working, erb is

327 views
Skip to first unread message

Erwin Bogaard

unread,
Nov 4, 2015, 8:24:59 AM11/4/15
to Puppet Users
As epp is the way to go, I'm trying to create all my new templates in epp-format.
I have a problem with using conditionals, though.

I have the following conditional in an epp template:
...
<%- if $xxx_yyy == true { -%>
// code here
<%- } -%>

...

When I apply this template with a defined type resource that sets:
...
        xxx_yyy     => true,
...

Nothing happens on that node.
Just to test what the value is of $xxx_yyy, I added "Value variable: <%= $xxx_yyy %>" to the templat, but that stays empty.

I call the epp-template with:
content => epp('module/template.epp'),

If I copy the template to template.erb and modify the code as needed:
...
<%- if @sug_saml_enable -%>
// code here
<%- end -%>

...

All is working well when calling the template with:
content => template('module/template.erb'),

What am I doing wrong?
Can someone point me in the right direction?

This is with puppet-agent 4.2.3 and the newest puppetserver.

math...@therussells.me

unread,
Nov 4, 2015, 8:34:11 AM11/4/15
to Puppet Users
I ran into this problem also. 

Are you access the variable $xxx_yyy will full puppet path? IE $classname::xxx_yyy

If not you need to pass the variable into the template like this. 

content => epp('module/template.epp',  { 'xxx_yyy' => "$xxx_yyy"}),

Hope This helps

Erwin Bogaard

unread,
Nov 4, 2015, 8:55:27 AM11/4/15
to Puppet Users
Aaron, thanks! That was the problem.
I think I misread (or didn't read) the paragraph "Accessing variables" in the documentation.
Thanks for helping me out with this.
Reply all
Reply to author
Forward
0 new messages