Template problems

63 views
Skip to first unread message

Ugo Bellavance

unread,
Mar 7, 2016, 10:32:04 PM3/7/16
to Puppet Users
Hi,

I'd like to be able to do something but I always get an error.

Here is my code:

<% if userotatelogs == false -%>

    CustomLog /var/log/httpd/<%= name %>/access.log combined

<% else -%>

    CustomLog "|/usr/sbin/rotatelogs <%= if @rotatelogsuselocaltime then '-l' end %> <%= if @rotatelogsforceopen then '-f' end %> <%= if @rotatelogsuselink then "-L /var/log/httpd/<%= name %>/access.log" end %> /var/log/httpd/<%= name %>/access.log.%Y-%m-%d <%= rotatelogstime %>" combined

<% end -%>


The problematic part seems to be the part in yellow.


Here is the error I get:


compile error /etc/puppet/modules/apache/templates/vhost-proxy_w_access.conf.erb:70: syntax error, unexpected $undefined, expecting kEND ...; _erbout.concat "/access.log\" end %> /var/log/httpd/"; _er...                               ^ /etc/puppet/modules/apache/templates/vhost-proxy_w_access.conf.erb:76: syntax error, unexpected $end, expecting ')' ; _erbout


I tried with single quotes, as <%= name %>, <%= @name %>, <%= $name %>, but it always fails.


Thanks,


Ugo

R.I.Pienaar

unread,
Mar 8, 2016, 1:30:38 AM3/8/16
to puppet...@googlegroups.com
You can't nest the <% %> inside another. Try:

<%= if @rotatelogsuselink then "-L /var/log/httpd/#{@name}/access.log" end %>

Everything inside is normal Ruby and that's how interpolation works there

---
R.I.Pienaar

Ugo Bellavance

unread,
Mar 8, 2016, 6:06:40 AM3/8/16
to Puppet Users
It works!

You guys are better than most vendor's service contract!

Thanks a lot!

Ugo

Ugo Bellavance

unread,
Mar 8, 2016, 7:50:46 AM3/8/16
to Puppet Users
Just a thought, where should I have looked for that? Is it pure Ruby?


On Tuesday, March 8, 2016 at 1:30:38 AM UTC-5, R.I. Pienaar wrote:

R.I.Pienaar

unread,
Mar 8, 2016, 8:11:46 AM3/8/16
to puppet-users


----- Original Message -----
> From: "Ugo Bellavance" <ug...@lubik.ca>
> To: "puppet-users" <puppet...@googlegroups.com>
> Sent: Tuesday, 8 March, 2016 13:50:46
> Subject: Re: [Puppet Users] Template problems

> Just a thought, where should I have looked for that? Is it pure Ruby?

yeah pretty much, there are template docs but this I guess is just confusing.

If you're on recent puppet you should try epp templates, they are written
using the puppet language so less context changing

Ugo Bellavance

unread,
Mar 9, 2016, 8:31:52 PM3/9/16
to Puppet Users
2.7.  Probably out of luck, as it is so old. 
Reply all
Reply to author
Forward
0 new messages