<% %> in template files


#1

I have a line I need to add to my rsyslog.conf.erb template, but chef
doesn’t seem to like it because it contains the characters <% and %> and
there’s not any ruby between them.

For example, I added this line to my template (it needs to be added to the
rsyslog.conf on all my nodes):

$template GRAYLOG2,"<%PRI%>1 %timegenerated:::date-rfc3339% %HOSTNAME%
%syslogtag% - %APP-NAME%: %msg:::drop-last-lf%\n"

but chef seems to be getting confused by <%PRI%>

What do people suggest to work around this? Is there some way I can escape
those characters in a template or tell chef to treat them literally and not
as a ruby command or variable marker?

Charles J. Burns
charlesburns@gmail.com


#2

Hey Charles,

You might try this:

On Tue, Oct 16, 2012 at 1:27 PM, Charles Burns charlesburns@gmail.com wrote:

I have a line I need to add to my rsyslog.conf.erb template, but chef
doesn’t seem to like it because it contains the characters <% and %> and
there’s not any ruby between them.

For example, I added this line to my template (it needs to be added to the
rsyslog.conf on all my nodes):

$template GRAYLOG2,"<%PRI%>1 %timegenerated:::date-rfc3339% %HOSTNAME%
%syslogtag% - %APP-NAME%: %msg:::drop-last-lf%\n"

but chef seems to be getting confused by <%PRI%>

What do people suggest to work around this? Is there some way I can escape
those characters in a template or tell chef to treat them literally and not
as a ruby command or variable marker?

Charles J. Burns
charlesburns@gmail.com


Kevin Karwaski
Operations Engineer @ {Fiksu}


#3

Awesome, will give that a shot, thanks!

On Tue, Oct 16, 2012 at 1:30 PM, Kevin Karwaski kkarwaski@fiksu.com wrote:

Hey Charles,

You might try this:

http://stackoverflow.com/questions/2322413/how-do-i-escape-erb-code-in-fixtures

On Tue, Oct 16, 2012 at 1:27 PM, Charles Burns charlesburns@gmail.com
wrote:

I have a line I need to add to my rsyslog.conf.erb template, but chef
doesn’t seem to like it because it contains the characters <% and %> and
there’s not any ruby between them.

For example, I added this line to my template (it needs to be added to
the
rsyslog.conf on all my nodes):

$template GRAYLOG2,"<%PRI%>1 %timegenerated:::date-rfc3339% %HOSTNAME%
%syslogtag% - %APP-NAME%: %msg:::drop-last-lf%\n"

but chef seems to be getting confused by <%PRI%>

What do people suggest to work around this? Is there some way I can
escape
those characters in a template or tell chef to treat them literally and
not
as a ruby command or variable marker?

Charles J. Burns
charlesburns@gmail.com


Kevin Karwaski
Operations Engineer @ {Fiksu}

Charles J. Burns
charlesburns@gmail.com


#4

That worked perfectly. <%%PRI%> in the template renders <%PRI%> in the
chef-generated file.

Thanks again!

On Tue, Oct 16, 2012 at 1:32 PM, Charles Burns charlesburns@gmail.comwrote:

Awesome, will give that a shot, thanks!

On Tue, Oct 16, 2012 at 1:30 PM, Kevin Karwaski kkarwaski@fiksu.comwrote:

Hey Charles,

You might try this:

http://stackoverflow.com/questions/2322413/how-do-i-escape-erb-code-in-fixtures

On Tue, Oct 16, 2012 at 1:27 PM, Charles Burns charlesburns@gmail.com
wrote:

I have a line I need to add to my rsyslog.conf.erb template, but chef
doesn’t seem to like it because it contains the characters <% and %> and
there’s not any ruby between them.

For example, I added this line to my template (it needs to be added to
the
rsyslog.conf on all my nodes):

$template GRAYLOG2,"<%PRI%>1 %timegenerated:::date-rfc3339% %HOSTNAME%
%syslogtag% - %APP-NAME%: %msg:::drop-last-lf%\n"

but chef seems to be getting confused by <%PRI%>

What do people suggest to work around this? Is there some way I can
escape
those characters in a template or tell chef to treat them literally and
not
as a ruby command or variable marker?

Charles J. Burns
charlesburns@gmail.com


Kevin Karwaski
Operations Engineer @ {Fiksu}

Charles J. Burns
charlesburns@gmail.com

Charles J. Burns
charlesburns@gmail.com