Hello, I am trying to setup a template with data being passed in as a long string of data which is being returned via extlookup() i.e. $resolvers = "10.10.10.10 11.11.11.11.12.12.12.12" The template should split those up and put a nameserver entry per line in /etc/resolv.conf I have this in the template now:- <%= scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each do | ns | %> nameserver <%= ns %> <% end -%> Which is throwing a syntax error. Can''t for the life of me work out whats wrong. Probably not had enough coffee yet. Any ideas ? Thanks Paul -- 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.
Hi, Is that variable declaration copied correctly?> $resolvers = "10.10.10.10 11.11.11.11.12.12.12.12"Should be> $resolvers = "10.10.10.10 11.11.11.11 12.12.12.12"what''s that do for you? Cheers Den On 23/01/2012, at 22:57, "OlliesDad@googlemail.com" <Paul.Seymour@barcap.com> wrote:> Hello, > > I am trying to setup a template with data being passed in as a long > string of data which is being returned via extlookup() > > i.e. $resolvers = "10.10.10.10 11.11.11.11.12.12.12.12" > > The template should split those up and put a nameserver entry per line > in /etc/resolv.conf > > I have this in the template now:- > <%= scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each > do | ns | %> > nameserver <%= ns %> > <% end -%> > > Which is throwing a syntax error. Can''t for the life of me work out > whats wrong. Probably not had enough coffee yet. > > Any ideas ? > > Thanks > Paul > > -- > 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.
On Jan 23, 1:17 pm, Denmat <tu2bg...@gmail.com> wrote:> Hi, > > Is that variable declaration copied correctly? > > > $resolvers = "10.10.10.10 11.11.11.11.12.12.12.12" > > Should be> $resolvers = "10.10.10.10 11.11.11.11 12.12.12.12" > > what''s that do for you? >That was a typo in my original mail. The syntax problem remains as it would still be a split on the spaces. Thanks Paul -- 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.
Absolutely beats me. Is this a verbatim paste from your template? Are you certain that the template is the source of the error? Does it say anything beyond "syntax error"? Just pasting puppet output would be ideal. Cheers, Felix On 01/23/2012 12:57 PM, OlliesDad@googlemail.com wrote:> I have this in the template now:- > <%= scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each > do | ns | %> > nameserver <%= ns %> > <% end -%> > > Which is throwing a syntax error. Can''t for the life of me work out > whats wrong. Probably not had enough coffee yet.-- 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 Jan 23, 1:32 pm, Felix Frank <felix.fr...@alumni.tu-berlin.de> wrote:> Absolutely beats me. > > Is this a verbatim paste from your template? > Are you certain that the template is the source of the error? > Does it say anything beyond "syntax error"? > > Just pasting puppet output would be ideal. >host: parse of /etc/resolv.conf failed ./resolver/templates/resolv.conf.erb:7:in `result'': compile error (SyntaxError) ./resolver/templates/resolv.conf.erb:4: syntax error _erbout.concat(( scope.lookupvar(''resolver::params::resolvers'').split(/ \s+/).each do | ns | ).to_s); _erbout.concat "\n" ^ ./resolver/templates/resolv.conf.erb:7: syntax error _erbout ^ from /usr/lib/ruby/1.8/erb.rb:741:in `value'' from /usr/lib/ruby/1.8/erb.rb:741:in `result'' from /usr/lib/ruby/site_ruby/1.8/puppet/parser/ templatewrapper.rb:106:in `result'' from /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:185:in `benchmark'' from /usr/lib/ruby/site_ruby/1.8/puppet/parser/ templatewrapper.rb:103:in `result'' from /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/ template.rb:18:in `function_template'' from /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/ template.rb:10:in `collect'' from /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/ template.rb:10:in `function_template'' ... 62 levels... from /usr/lib/ruby/site_ruby/1.8/puppet/application.rb:401:in `exit_on_fail'' from /usr/lib/ruby/site_ruby/1.8/puppet/application.rb:306:in `run'' from /usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb: 69:in `execute'' from /usr/bin/puppet:4 # -- 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 01/23/2012 02:48 PM, OlliesDad@googlemail.com wrote:> host: parse of /etc/resolv.conf failed > ./resolver/templates/resolv.conf.erb:7:in `result'': compile error > (SyntaxError) > ./resolver/templates/resolv.conf.erb:4: syntax error > _erbout.concat(( scope.lookupvar(''resolver::params::resolvers'').split(/ > \s+/).each do | ns | ).to_s); _erbout.concat "\n" > > ^ > ./resolver/templates/resolv.conf.erb:7: syntax error > _erboutUhuh. Just a wild guess, but: *Does* your template end in a newline character? If not, add one. If in doubt, loose the ''-%>'' and substitute ''%>'' instead. HTH, Felix -- 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 Jan 23, 4:32 pm, Felix Frank <felix.fr...@alumni.tu-berlin.de> wrote:> On 01/23/2012 02:48 PM, Ollies...@googlemail.com wrote: > > > host: parse of /etc/resolv.conf failed > > ./resolver/templates/resolv.conf.erb:7:in `result'': compile error > > (SyntaxError) > > ./resolver/templates/resolv.conf.erb:4: syntax error > > _erbout.concat(( scope.lookupvar(''resolver::params::resolvers'').split(/ > > \s+/).each do | ns | ).to_s); _erbout.concat "\n" > > > ^ > > ./resolver/templates/resolv.conf.erb:7: syntax error > > _erbout > > Uhuh. Just a wild guess, but: *Does* your template end in a newline > character? > If not, add one. If in doubt, loose the ''-%>'' and substitute ''%>'' instead. > > HTH, > FelixLooks about right to me. Thanks for the continued help. Cheers Paul -- 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.
Is your issue resolved? It looks like you don''t have the correct erb syntax in your loop *<%=* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each I think should be *<%* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each On Mon, Jan 23, 2012 at 4:00 PM, OlliesDad@googlemail.com < Paul.Seymour@barcap.com> wrote:> > > On Jan 23, 4:32 pm, Felix Frank <felix.fr...@alumni.tu-berlin.de> > wrote: > > On 01/23/2012 02:48 PM, Ollies...@googlemail.com wrote: > > > > > host: parse of /etc/resolv.conf failed > > > ./resolver/templates/resolv.conf.erb:7:in `result'': compile error > > > (SyntaxError) > > > ./resolver/templates/resolv.conf.erb:4: syntax error > > > _erbout.concat(( scope.lookupvar(''resolver::params::resolvers'').split(/ > > > \s+/).each do | ns | ).to_s); _erbout.concat "\n" > > > > > ^ > > > ./resolver/templates/resolv.conf.erb:7: syntax error > > > _erbout > > > > Uhuh. Just a wild guess, but: *Does* your template end in a newline > > character? > > If not, add one. If in doubt, loose the ''-%>'' and substitute ''%>'' > instead. > > > > HTH, > > Felix > > Looks about right to me. > > Thanks for the continued help. > > Cheers > Paul > > -- > 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.
On Jan 23, 9:07 pm, Guy Matz <gm...@matz.org> wrote:> Is your issue resolved? It looks like you don''t have the correct erb > syntax in your loop > > *<%=* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each > > I think should be > > *<%* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each >Thanks Gary, the split now works. Although I get an line break. # more /etc/resolv.conf # File managed by puppet domain example.com searchpath example.com example2.com nameserver 10.10.10.10 nameserver 11.11.11.11 -- 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 Jan 24, 7:14 am, "Ollies...@googlemail.com" <Paul.Seym...@barcap.com> wrote:> On Jan 23, 9:07 pm, Guy Matz <gm...@matz.org> wrote: > > > Is your issue resolved? It looks like you don''t have the correct erb > > syntax in your loop > > > *<%=* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each > > > I think should be > > > *<%* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each > > Thanks Gary, the split now works. Although I get an line break. > > # more /etc/resolv.conf > # File managed by puppet > domain example.com > searchpath example.com example2.com > > nameserver 10.10.10.10 > > nameserver 11.11.11.11No worries sorted that with:- <% scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each do | ns | -%> nameserver <%= ns %> <% end -%> Thanks to all for the help. -- 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.
Dan White
2012-Jan-24 14:30 UTC
[Puppet Users] A Related Question - (Was: Template Help Please)
What is the minimum version of puppet (and other bits) that this technique will work on ? I am still on 2.6 (latest in EPEL) and I have the impression that this is 2.7+ stuff. “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- OlliesDad@googlemail.com <Paul.Seymour@barcap.com> wrote:> > > On Jan 24, 7:14 am, "Ollies...@googlemail.com" > <Paul.Seym...@barcap.com> wrote: > > On Jan 23, 9:07 pm, Guy Matz <gm...@matz.org> wrote: > > > > > Is your issue resolved? It looks like you don''t have the correct erb > > > syntax in your loop > > > > > *<%=* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each > > > > > I think should be > > > > > *<%* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each > > > > Thanks Gary, the split now works. Although I get an line break. > > > > # more /etc/resolv.conf > > # File managed by puppet > > domain example.com > > searchpath example.com example2.com > > > > nameserver 10.10.10.10 > > > > nameserver 11.11.11.11 > > No worries sorted that with:- > <% scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each do > | ns | -%> > nameserver <%= ns %> > <% end -%> > > Thanks to all for the help. > > -- > 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.
Dick Davies
2012-Jan-26 13:20 UTC
Re: [Puppet Users] A Related Question - (Was: Template Help Please)
That kind of thing should work (been using similar tricks since 0.25.x); one odd thing about Puppet is you have more flexibility in templates than in the DSL itself (since erb opens up the full Ruby syntax). On 24 January 2012 14:30, Dan White <ygor@comcast.net> wrote:> What is the minimum version of puppet (and other bits) that this technique will work on ? > > I am still on 2.6 (latest in EPEL) and I have the impression that this is 2.7+ stuff. > > “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” > Bill Waterson (Calvin & Hobbes) > > ----- OlliesDad@googlemail.com <Paul.Seymour@barcap.com> wrote: >> >> >> On Jan 24, 7:14 am, "Ollies...@googlemail.com" >> <Paul.Seym...@barcap.com> wrote: >> > On Jan 23, 9:07 pm, Guy Matz <gm...@matz.org> wrote: >> > >> > > Is your issue resolved? It looks like you don''t have the correct erb >> > > syntax in your loop >> > >> > > *<%=* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each >> > >> > > I think should be >> > >> > > *<%* scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each >> > >> > Thanks Gary, the split now works. Although I get an line break. >> > >> > # more /etc/resolv.conf >> > # File managed by puppet >> > domain example.com >> > searchpath example.com example2.com >> > >> > nameserver 10.10.10.10 >> > >> > nameserver 11.11.11.11 >> >> No worries sorted that with:- >> <% scope.lookupvar(''resolver::params::resolvers'').split(/\s+/).each do >> | ns | -%> >> nameserver <%= ns %> >> <% end -%> >> >> Thanks to all for the help. >> >> -- >> 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. >-- 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.
Felix Frank
2012-Jan-26 13:22 UTC
Re: [Puppet Users] A Related Question - (Was: Template Help Please)
On 01/26/2012 02:20 PM, Dick Davies wrote:> That kind of thing should work (been using similar tricks since 0.25.x);I think Dan was addressing this:> scope.lookupvar(''resolver::params::resolvers'')I''m not sure when this was new, I believe it works with 2.6.x -- 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.
Dan White
2012-Jan-26 14:22 UTC
Re: [Puppet Users] A Related Question - (Was: Template Help Please)
Thanks for replying. I will try it on my 2.6.12 and report back to the list “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- Felix Frank <felix.frank@alumni.tu-berlin.de> wrote:> On 01/26/2012 02:20 PM, Dick Davies wrote: > > That kind of thing should work (been using similar tricks since 0.25.x); > > I think Dan was addressing this: > > > scope.lookupvar(''resolver::params::resolvers'') > > I''m not sure when this was new, I believe it works with 2.6.x > > -- > 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.