Hiya, I''ve recently updated my svn server so that it checks the syntax of .erb files, on commit, along with .pp files. While doing this, I ran across a small but niggling issue and wanted to see if I was just doing something wrong or if it was a bug. In my sudoers template file, I have a number of lines that start along the lines of: %sup ALL=NOPASSWD: ALL %mon ALL=NOPASSWD: ALL I''ve never had any problems with this template, but upon checking the file with: erb -x -T ''-'' sudoers.erb | ruby -c Which gives the error: -:28: syntax error, unexpected '':'', expecting $end ; sup ALL=NOPASSWD: ALL So.. after a bit of investigation, I found the following line in the ruby docs (http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/erb/rdoc/index.html) "% a line of Ruby code -- treated as <% line %> (optional -- see ERB.new) %% replaced with % if first thing on a line and % processing is used" Awesome! That explains that then! So I updated my template to read: %%sup ALL=NOPASSWD: ALL %%mon ALL=NOPASSWD: ALL Ran it past erb.. no error.. sorted!.... Except.. When I actually use that template within puppet.. the %% is not evaluated and the double %% ends up being placed in the generated file too.. I realise that one solution here is to just not check the syntax of the template with erb (as it works absolutely fine with a single %).. However, it feels a little bit broken or (quite possibly) I''m missing something obvious so would be good to get some feedback. Thanks in advance! -- Tim tim@yetanother.net -- 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.
On Tue, Jul 6, 2010 at 12:52 AM, Tim <tim@yetanother.net> wrote:> > I realise that one solution here is to just not check the syntax of > the template with erb (as it works absolutely fine with a single %).. > However, it feels a little bit broken or (quite possibly) I''m missing > something obvious so would be good to get some feedback.Tim, The -P erb switch should disable this behavior and cause erb to behave more closely to puppet with lines begenning with % in templates. $ erb --help erb [switches] [inputfile] ... -P ignore lines which start with "%" Hope this helps, -- Jeff McCune http://www.puppetlabs.com/ -- 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.
Cheers Jeff, that''s just what I was after :) On Tue, Jul 6, 2010 at 5:00 PM, Jeff McCune <jeff@puppetlabs.com> wrote:> On Tue, Jul 6, 2010 at 12:52 AM, Tim <tim@yetanother.net> wrote: >> >> I realise that one solution here is to just not check the syntax of >> the template with erb (as it works absolutely fine with a single %).. >> However, it feels a little bit broken or (quite possibly) I''m missing >> something obvious so would be good to get some feedback. > > Tim, > > The -P erb switch should disable this behavior and cause erb to behave > more closely to puppet with lines begenning with % in templates. > > $ erb --help > erb [switches] [inputfile] > ... > -P ignore lines which start with "%" > > Hope this helps, > -- > Jeff McCune > http://www.puppetlabs.com/ > > -- > 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. > >-- Tim tim@yetanother.net -- 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.