Hi, I have a template named rsyslog.conf.erb, and the puppet agents seem to be choking on this: **.notice;news.none;cron.none @loghost:514* The agents report an error of ": bad URI(is not URI?): " followed by a bunch of jargon. I''m pretty sure its the literal ''@'' symbol that its trying to evaluate as erb code. How can I escape this @ symbol so its a literal? Thanks. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/sCbRpNM8LikJ. 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.
Krzysztof Wilczynski
2012-Aug-31 15:21 UTC
[Puppet Users] Re: Literal @ character in erb template
Hi, I am not sure how your template looks like, or how do you render it, but try to avoid putting anything with @ into a <%= %> block. It should just work: matti@acrux ~ $ irb>> require ''erb''=> true>> host = ''localhost''=> "localhost">> p ERB.new(''*.notice;news.none;cron.none @<%= host%>:514'').result(binding) "*.notice;news.none;cron.none @localhost:514" => nil>> @host = host.clone=> "localhost">> p ERB.new(''*.notice;news.none;cron.none @<%= @host%>:514'').result(binding) "*.notice;news.none;cron.none @localhost:514" => nil>>matti@acrux ~ $ cat | puppet apply --noop notice inline_template(''*.notice;news.none;cron.none @<%= @hostname %>:514'') notice: Scope(Class[main]): *.notice;news.none;cron.none @acrux:514 notice: Finished catalog run in 0.03 seconds matti@acrux ~ $ KW On Friday, 31 August 2012 15:09:17 UTC+1, banjer wrote:> > Hi, > I have a template named rsyslog.conf.erb, and the puppet agents seem to be > choking on this: > > **.notice;news.none;cron.none @loghost:514* > > > The agents report an error of ": bad URI(is not URI?): " followed by a > bunch of jargon. I''m pretty sure its the literal ''@'' symbol that its > trying to evaluate as erb code. How can I escape this @ symbol so its a > literal? Thanks. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/wjllu71o0ZMJ. 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.
Thanks for the reply KW, but thats not quite what I was asking. Heres the relevant section of the template: *.notice;news.none;cron.none @loghost:514 <% if @hostname == "foo" %> # Provides UDP syslog reception $ModLoad imudp.so $UDPServerRun 514 <% end %> So you can see it lives outside of a <% %> block. This part: "*.notice;news.none;cron.none @loghost:514*" *should be a literal string. Its a standard rsyslog configuration. "Loghost" is the actual hostname of a host in our network that we send all of our servers'' syslogs to. In other words, I don''t want it to be evaluated as ERB code. So how can I have puppet/the template engine ignore the ''@'' symbol and treat it as a literal string? On Friday, August 31, 2012 11:21:08 AM UTC-4, Krzysztof Wilczynski wrote:> > Hi, > > I am not sure how your template looks like, or how do you render it, but > try to avoid putting anything with @ into a <%= %> block. It should just > work: > > matti@acrux ~ $ irb > >> require ''erb'' > => true > >> host = ''localhost'' > => "localhost" > >> p ERB.new(''*.notice;news.none;cron.none @<%= host > %>:514'').result(binding) > "*.notice;news.none;cron.none @localhost:514" > => nil > >> @host = host.clone > => "localhost" > >> p ERB.new(''*.notice;news.none;cron.none @<%= @host > %>:514'').result(binding) > "*.notice;news.none;cron.none @localhost:514" > => nil > >> > > matti@acrux ~ $ cat | puppet apply --noop > notice inline_template(''*.notice;news.none;cron.none @<%= @hostname > %>:514'') notice: Scope(Class[main]): > *.notice;news.none;cron.none @acrux:514 > notice: Finished catalog run in 0.03 seconds > matti@acrux ~ $ > > KW > > On Friday, 31 August 2012 15:09:17 UTC+1, banjer wrote: >> >> Hi, >> I have a template named rsyslog.conf.erb, and the puppet agents seem to >> be choking on this: >> >> **.notice;news.none;cron.none @loghost:514* >> >> >> The agents report an error of ": bad URI(is not URI?): " followed by a >> bunch of jargon. I''m pretty sure its the literal ''@'' symbol that its >> trying to evaluate as erb code. How can I escape this @ symbol so its a >> literal? Thanks. >> >> >>-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/8e0XGAVVVeIJ. 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.
Krzysztof Wilczynski
2012-Aug-31 20:37 UTC
[Puppet Users] Re: Literal @ character in erb template
Hi, Works fine for me: matti@acrux ~ $ cat > test.erb *.notice;news.none;cron.none @loghost:514 <% if @hostname == "foo" %> # Provides UDP syslog reception $ModLoad imudp.so $UDPServerRun 514 <% end %> matti@acrux ~ $ sed -i ''s/foo/acrux/'' test.erb matti@acrux ~ $ cat | puppet apply file { ''/tmp/test.txt'': content => template(''/tmp/test.erb'') } notice: /Stage[main]//File[/tmp/test.txt]/ensure: defined content as ''{md5}c3230100f527db4f0fe50e200ed99fe9'' notice: Finished catalog run in 0.06 seconds matti@acrux ~ $ cat /tmp/test.txt *.notice;news.none;cron.none @loghost:514 # Provides UDP syslog reception $ModLoad imudp.so $UDPServerRun 514 matti@acrux ~ $ KW On Friday, August 31, 2012 6:40:26 PM UTC+1, banjer wrote:> > Thanks for the reply KW, but thats not quite what I was asking. Heres the > relevant section of the template: > > > *.notice;news.none;cron.none @loghost:514 > > <% if @hostname == "foo" %> > # Provides UDP syslog reception > $ModLoad imudp.so > $UDPServerRun 514 > <% end %> > > So you can see it lives outside of a <% %> block. > > This part: "*.notice;news.none;cron.none @loghost:514*" *should be a > literal string. Its a standard rsyslog configuration. "Loghost" is the > actual hostname of a host in our network that we send all of our servers'' > syslogs to. In other words, I don''t want it to be evaluated as ERB code. > So how can I have puppet/the template engine ignore the ''@'' symbol and > treat it as a literal string? > > > > > On Friday, August 31, 2012 11:21:08 AM UTC-4, Krzysztof Wilczynski wrote: >> >> Hi, >> >> I am not sure how your template looks like, or how do you render it, but >> try to avoid putting anything with @ into a <%= %> block. It should just >> work: >> >> matti@acrux ~ $ irb >> >> require ''erb'' >> => true >> >> host = ''localhost'' >> => "localhost" >> >> p ERB.new(''*.notice;news.none;cron.none @<%= host >> %>:514'').result(binding) >> "*.notice;news.none;cron.none @localhost:514" >> => nil >> >> @host = host.clone >> => "localhost" >> >> p ERB.new(''*.notice;news.none;cron.none @<%= @host >> %>:514'').result(binding) >> "*.notice;news.none;cron.none @localhost:514" >> => nil >> >> >> >> matti@acrux ~ $ cat | puppet apply --noop >> notice inline_template(''*.notice;news.none;cron.none @<%= @hostname >> %>:514'') notice: Scope(Class[main]): >> *.notice;news.none;cron.none @acrux:514 >> notice: Finished catalog run in 0.03 seconds >> matti@acrux ~ $ >> >> KW >> >> On Friday, 31 August 2012 15:09:17 UTC+1, banjer wrote: >>> >>> Hi, >>> I have a template named rsyslog.conf.erb, and the puppet agents seem to >>> be choking on this: >>> >>> **.notice;news.none;cron.none @loghost:514* >>> >>> >>> The agents report an error of ": bad URI(is not URI?): " followed by a >>> bunch of jargon. I''m pretty sure its the literal ''@'' symbol that its >>> trying to evaluate as erb code. How can I escape this @ symbol so its a >>> literal? Thanks. >>> >>> >>>-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/U6pC8D80PeQJ. 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 Friday, August 31, 2012 3:37:48 PM UTC-5, Krzysztof Wilczynski wrote:> > Hi, > > Works fine for me: >>>>More generally, the underlying ERB engine will treat anything in your template but outside ERB blocks (delimited by <% %> or <%= %> or <%# %>) as literal text, except for <%% (which is translated to <% in the output) and %%> (which is translated to %>). Without the actual error message (or, apparently, the template that causes it) I can only speculate about what the problem may be, but one thing to look for would be proper closure of all ERB code blocks before the template text where the error is reported. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/wqOG2_ci6ScJ. 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.
The puppet error was: err: Failed to apply catalog: Parameter source failed: Could not understand source # This file managed by Puppet Sorry for not seeing that error before...I kept looking at the "Bad URI" error message which I posted in my original email. So anyway, it turns out I was using ''source'' instead of ''content'' within my file declaration in my manifest. My working file resource looks like this now: file { "rsyslog.conf": path => "/etc/rsyslog.conf", owner => root, group => root, mode => 644, content => template(''syslog/rsyslog.conf.erb''), require => Package["rsyslog"], } All good now. Thanks for the assistance, it gave me a few pointers on troubleshooting templates and puppet manifests. On Tuesday, September 4, 2012 9:03:01 AM UTC-4, jcbollinger wrote:> > > On Friday, August 31, 2012 3:37:48 PM UTC-5, Krzysztof Wilczynski wrote: >> >> Hi, >> >> Works fine for me: >> > >>>> > More generally, the underlying ERB engine will treat anything in your > template but outside ERB blocks (delimited by <% %> or <%= %> or <%# %>) as > literal text, except for <%% (which is translated to <% in the output) and > %%> (which is translated to %>). > > Without the actual error message (or, apparently, the template that causes > it) I can only speculate about what the problem may be, but one thing to > look for would be proper closure of all ERB code blocks before the template > text where the error is reported. > > > John > > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/FFFd505T5A0J. 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 Aug 31, 2012, at 10:40 AM, banjer wrote:> Thanks for the reply KW, but thats not quite what I was asking. Heres the relevant section of the template: > > > *.notice;news.none;cron.none @loghost:514 > > <% if @hostname == "foo" %> > # Provides UDP syslog reception > $ModLoad imudp.so > $UDPServerRun 514 > <% end %> > > So you can see it lives outside of a <% %> block.Since you didn''t seem to get an answer, I think you need to reread the above. The problem isn''t the loghost line. Your if statement clearly uses a @ character before hostname. I suspect that this is your only problem, and removing the @ will solve your problem. -- Jo Rhett Net Consonance : net philanthropy to improve open source and internet projects. -- 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.
Jo, I did figure it out, not sure if you saw my last post on this. Per my last post I said, "it turns out I was using ''source'' instead of ''content'' within my file declaration in my manifest." So it had nothing to do with the erb file at all. Regarding the @ symbol, it was a red herring. In fact, I have the "<% if @hostname == "foo" %>" statement in a bunch of different templates in several of my puppet modules, and that statement works beautifully. On Tue, Sep 18, 2012 at 7:20 PM, Jo Rhett <jrhett@netconsonance.com> wrote:> > On Aug 31, 2012, at 10:40 AM, banjer wrote: > > Thanks for the reply KW, but thats not quite what I was asking. Heres the > relevant section of the template: > > > *.notice;news.none;cron.none @loghost:514 > > <% if @hostname == "foo" %> > # Provides UDP syslog reception > $ModLoad imudp.so > $UDPServerRun 514 > <% end %> > > So you can see it lives outside of a <% %> block. > > > Since you didn''t seem to get an answer, I think you need to reread the > above. The problem isn''t the loghost line. Your if statement clearly uses a > @ character before hostname. I suspect that this is your only problem, and > removing the @ will solve your problem. > > -- > Jo Rhett > Net Consonance : net philanthropy to improve open source and internet > projects. > > > > -- > 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.