Justin Lloyd
2011-Nov-18 19:02 UTC
[Puppet Users] Are tildes actually valid in templates or is this a bug?
Hi all,
First off, we''re running Puppet 2.7.6 with Ruby 1.8.7 on CentOS 6.0.
Now, I''m using tildes in a template to prevent newlines from appearing
but
ruby/puppet is choking on them.
*/tmp/puppet$ cat test.erb*
Line 1: Line 2 will exist if running on CentOS.
<% if operatingsystem == "CentOS" ~%>
Line 2: Yay, we''re running CentOS.
<% end ~%>
*/tmp/puppet$ erb -x -T ''-'' test.erb | ruby -c*
-:2: syntax error, unexpected ''~'', expecting kTHEN or
'':'' or ''\n'' or '';''
; if operatingsystem == "CentOS" ~; _erbout.concat "\n"
^
-:4: syntax error, unexpected kEND, expecting $end
; end ~; _erbout.concat "\n"
^
*/tmp/puppet**$ perl -pi -e ''s/~//'' test.erb*
*/tmp/puppet$ erb -x -T ''-'' test.erb | ruby -c*
Syntax OK
*/tmp/puppet$ *
I thought it might just be erb/ruby that was choking so I did a full test
with puppet. Tildes still do not work but, without them, blank lines are
still generated.
*/tmp/puppet$ cat test.pp*
class test {
file { "/tmp/puppet/test.out":
ensure => ''present'',
content => template(''test.erb''),
}
}
include test**
*/tmp/puppet$ puppet apply --templatedir=. test.pp*
/tmp/puppet/test.erb:4:in `result'': compile error (SyntaxError)
/tmp/puppet/test.erb:2: syntax error, unexpected ''~'',
expecting kTHEN or
'':'' or ''\n'' or '';''
... operatingsystem == "CentOS" ~; _erbout.concat "\nLine 2:
Ya...
^
/tmp/puppet/test.erb:4: syntax error, unexpected kEND, expecting $end
; end ~; _erbout.concat "\n"
^
from
/usr/lib/ruby/site_ruby/1.8/puppet/parser/templatewrapper.rb:106:in
`result''
[STRIPPED OUT STACK TRACE FOR READABILITY]
*/tmp/puppet$ perl -pi -e ''s/~//'' test.erb*
*/tmp/puppet$ cat test.erb*
Line 1: Line 2 will exist if running on CentOS.
<% if operatingsystem == "CentOS" %>
Line 2: Yay, we''re running CentOS.
<% end %>
*/tmp/puppet$ puppet apply --templatedir=. test.pp*
notice: /Stage[main]/Test/File[/tmp/puppet/test.out]/ensure: created
notice: Finished catalog run in 0.04 seconds
*/tmp/puppet$ cat test.out*
Line 1: Line 2 will exist if running on CentOS.
Line 2: Yay, we''re running CentOS.
*/tmp/puppet$
*
Current examples I find all use tildes. Am I doing something wrong or could
there be a bug here?
Thanks,
Justin
*
*
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2011-Nov-18 19:05 UTC
Re: [Puppet Users] Are tildes actually valid in templates or is this a bug?
On Fri, Nov 18, 2011 at 2:02 PM, Justin Lloyd <jstnlld@gmail.com> wrote:> Hi all, > > First off, we''re running Puppet 2.7.6 with Ruby 1.8.7 on CentOS 6.0. > > Now, I''m using tildes in a template to prevent newlines from appearing but > ruby/puppet is choking on them. > > /tmp/puppet$ cat test.erb > Line 1: Line 2 will exist if running on CentOS. > <% if operatingsystem == "CentOS" ~%> > Line 2: Yay, we''re running CentOS. > <% end ~%> > /tmp/puppet$ erb -x -T ''-'' test.erb | ruby -c > -:2: syntax error, unexpected ''~'', expecting kTHEN or '':'' or ''\n'' or '';'' > ; if operatingsystem == "CentOS" ~; _erbout.concat "\n" > ^ > -:4: syntax error, unexpected kEND, expecting $end > ; end ~; _erbout.concat "\n" > ^ > /tmp/puppet$ perl -pi -e ''s/~//'' test.erb > /tmp/puppet$ erb -x -T ''-'' test.erb | ruby -c > Syntax OK > /tmp/puppet$ > > I thought it might just be erb/ruby that was choking so I did a full test > with puppet. Tildes still do not work but, without them, blank lines are > still generated. > > /tmp/puppet$ cat test.pp > class test { > file { "/tmp/puppet/test.out": > ensure => ''present'', > content => template(''test.erb''), > } > } > include test > /tmp/puppet$ puppet apply --templatedir=. test.pp > /tmp/puppet/test.erb:4:in `result'': compile error (SyntaxError) > /tmp/puppet/test.erb:2: syntax error, unexpected ''~'', expecting kTHEN or '':'' > or ''\n'' or '';'' > ... operatingsystem == "CentOS" ~; _erbout.concat "\nLine 2: Ya... > ^ > /tmp/puppet/test.erb:4: syntax error, unexpected kEND, expecting $end > ; end ~; _erbout.concat "\n" > ^ > from /usr/lib/ruby/site_ruby/1.8/puppet/parser/templatewrapper.rb:106:in > `result'' > [STRIPPED OUT STACK TRACE FOR READABILITY] > /tmp/puppet$ perl -pi -e ''s/~//'' test.erb > /tmp/puppet$ cat test.erb > Line 1: Line 2 will exist if running on CentOS. > <% if operatingsystem == "CentOS" %> > Line 2: Yay, we''re running CentOS. > <% end %> > /tmp/puppet$ puppet apply --templatedir=. test.pp > notice: /Stage[main]/Test/File[/tmp/puppet/test.out]/ensure: created > notice: Finished catalog run in 0.04 seconds > /tmp/puppet$ cat test.out > Line 1: Line 2 will exist if running on CentOS. > > Line 2: Yay, we''re running CentOS. > > /tmp/puppet$ > > Current examples I find all use tildes. Am I doing something wrong or could > there be a bug here?It''s dash not tilde -%> to suppress newlines. Do you have a link to the faulty examples on puppetlabs site? Thanks, Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Justin Lloyd
2011-Nov-18 19:08 UTC
Re: [Puppet Users] Are tildes actually valid in templates or is this a bug?
/sigh. I just need to increase my font size. Thank you for pointing out a dumb mistake. Justin On Fri, Nov 18, 2011 at 11:05 AM, Nan Liu <nan@puppetlabs.com> wrote:> On Fri, Nov 18, 2011 at 2:02 PM, Justin Lloyd <jstnlld@gmail.com> wrote: > > Hi all, > > > > First off, we''re running Puppet 2.7.6 with Ruby 1.8.7 on CentOS 6.0. > > > > Now, I''m using tildes in a template to prevent newlines from appearing > but > > ruby/puppet is choking on them. > > > > /tmp/puppet$ cat test.erb > > Line 1: Line 2 will exist if running on CentOS. > > <% if operatingsystem == "CentOS" ~%> > > Line 2: Yay, we''re running CentOS. > > <% end ~%> > > /tmp/puppet$ erb -x -T ''-'' test.erb | ruby -c > > -:2: syntax error, unexpected ''~'', expecting kTHEN or '':'' or ''\n'' or '';'' > > ; if operatingsystem == "CentOS" ~; _erbout.concat "\n" > > ^ > > -:4: syntax error, unexpected kEND, expecting $end > > ; end ~; _erbout.concat "\n" > > ^ > > /tmp/puppet$ perl -pi -e ''s/~//'' test.erb > > /tmp/puppet$ erb -x -T ''-'' test.erb | ruby -c > > Syntax OK > > /tmp/puppet$ > > > > I thought it might just be erb/ruby that was choking so I did a full test > > with puppet. Tildes still do not work but, without them, blank lines are > > still generated. > > > > /tmp/puppet$ cat test.pp > > class test { > > file { "/tmp/puppet/test.out": > > ensure => ''present'', > > content => template(''test.erb''), > > } > > } > > include test > > /tmp/puppet$ puppet apply --templatedir=. test.pp > > /tmp/puppet/test.erb:4:in `result'': compile error (SyntaxError) > > /tmp/puppet/test.erb:2: syntax error, unexpected ''~'', expecting kTHEN or > '':'' > > or ''\n'' or '';'' > > ... operatingsystem == "CentOS" ~; _erbout.concat "\nLine 2: Ya... > > ^ > > /tmp/puppet/test.erb:4: syntax error, unexpected kEND, expecting $end > > ; end ~; _erbout.concat "\n" > > ^ > > from > /usr/lib/ruby/site_ruby/1.8/puppet/parser/templatewrapper.rb:106:in > > `result'' > > [STRIPPED OUT STACK TRACE FOR READABILITY] > > /tmp/puppet$ perl -pi -e ''s/~//'' test.erb > > /tmp/puppet$ cat test.erb > > Line 1: Line 2 will exist if running on CentOS. > > <% if operatingsystem == "CentOS" %> > > Line 2: Yay, we''re running CentOS. > > <% end %> > > /tmp/puppet$ puppet apply --templatedir=. test.pp > > notice: /Stage[main]/Test/File[/tmp/puppet/test.out]/ensure: created > > notice: Finished catalog run in 0.04 seconds > > /tmp/puppet$ cat test.out > > Line 1: Line 2 will exist if running on CentOS. > > > > Line 2: Yay, we''re running CentOS. > > > > /tmp/puppet$ > > > > Current examples I find all use tildes. Am I doing something wrong or > could > > there be a bug here? > > It''s dash not tilde -%> to suppress newlines. Do you have a link to > the faulty examples on puppetlabs site? > > Thanks, > > Nan > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.