How come this doesnt work? I write this in a normal ruby script it works just fine. <% for cpu in (0..processorcount) %> I want to loop through the number of processor so a specific action can be taken to generate content for a file. I get an error on the master of: bad value for range at /etc/puppet" -Chris -- 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=.
2009/11/19 Christopher Johnston <chjohnst@gmail.com>:> How come this doesnt work? I write this in a normal ruby script it > works just fine. > > <% for cpu in (0..processorcount) %> > > I want to loop through the number of processor so a specific action > can be taken to generate content for a file. I get an error on the > master of: > > bad value for range at /etc/puppet"Processorcount isn''t resolved. What machine are you running it on? What version of facter do you have?>> processorcount=nil=> nil>> for cpu in (0..processorcount) >> puts cpu >> endArgumentError: bad value for range from (irb):2>>Cheers J. -- 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=.
Its definitely there.. I even put a <%= processorcount %> to make sure the variable is set. <% processorcount.to_i-1 %> <% for cpu in (0..processorcount) %> Facter version is 1.52 # facter | grep proc processor0 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz processor1 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz processor2 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz processor3 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz processorcount => 4 On Mon, Nov 23, 2009 at 5:11 AM, Julian Simpson <simpsonjulian@gmail.com>wrote:> 2009/11/19 Christopher Johnston <chjohnst@gmail.com>: > > How come this doesnt work? I write this in a normal ruby script it > > works just fine. > > > > <% for cpu in (0..processorcount) %> > > > > I want to loop through the number of processor so a specific action > > can be taken to generate content for a file. I get an error on the > > master of: > > > > bad value for range at /etc/puppet" > > Processorcount isn''t resolved. What machine are you running it on? > What version of facter do you have? > > >> processorcount=nil > => nil > >> for cpu in (0..processorcount) > >> puts cpu > >> end > ArgumentError: bad value for range > from (irb):2 > >> > > Cheers > > J. > > -- > > 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<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=. > > >-- 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=.
On 23 Nov 2009, at 7:33 AM, Christopher Johnston wrote:> Its definitely there.. I even put a <%= processorcount %> to make > sure the variable is set. > > <% processorcount.to_i-1 %> > <% for cpu in (0..processorcount) %>Try: <% for cpu in (0 .. processorcount.to_i) %> -- Ian Ward Comfort <icomfort@rescomp.stanford.edu> Systems Team Lead, Student Computing, Stanford University -- 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.
2009/11/23 Christopher Johnston <chjohnst@gmail.com>:> Its definitely there.. I even put a <%= processorcount %> to make sure the > variable is set. > <% processorcount.to_i-1 %> > <% for cpu in (0..processorcount) %> > Facter version is 1.52 > # facter | grep proc > processor0 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz > processor1 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz > processor2 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz > processor3 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz > processorcount => 4And the <%= processorcount %> snippet resolved to 4 in your template? I''m stumped then. I thought you could do iteration with any ERB template, not just in Rails. J. -- 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=.
Yes it prints 4 directly into the file, but I cant put processorcount into the loop. Works fine in ruby but erb fails. Any ideas here on how to do this? I need to be able to determine the number of processors on the systems so I can generate a configuration file (loop through each processor number). -Chris On Mon, Nov 23, 2009 at 5:35 PM, Julian Simpson <simpsonjulian@gmail.com>wrote:> 2009/11/23 Christopher Johnston <chjohnst@gmail.com>: > > Its definitely there.. I even put a <%= processorcount %> to make sure > the > > variable is set. > > <% processorcount.to_i-1 %> > > <% for cpu in (0..processorcount) %> > > Facter version is 1.52 > > # facter | grep proc > > processor0 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz > > processor1 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz > > processor2 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz > > processor3 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz > > processorcount => 4 > > And the <%= processorcount %> snippet resolved to 4 in your template? > > I''m stumped then. I thought you could do iteration with any ERB > template, not just in Rails. > > J. > > -- > > 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<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=. > > >-- 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=.
On 23 Nov 2009, at 3:41 PM, Christopher Johnston wrote:> Yes it prints 4 directly into the file, but I cant put > processorcount into the loop. Works fine in ruby but erb fails. > Any ideas here on how to do this? I need to be able to determine > the number of processors on the systems so I can generate a > configuration file (loop through each processor number).>> <% for cpu in (0..processorcount) %>Try: <% for cpu in (0 .. processorcount.to_i) %> -- Ian Ward Comfort <icomfort@rescomp.stanford.edu> Systems Team Lead, Student Computing, Stanford University -- 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 Mon, Nov 23, 2009 at 3:41 PM, Christopher Johnston <chjohnst@gmail.com>wrote:> Yes it prints 4 directly into the file, but I cant put processorcount into > the loop. Works fine in ruby but erb fails. Any ideas here on how to do > this? I need to be able to determine the number of processors on the > systems so I can generate a configuration file (loop through each processor > number). > > -Chris >Chris, Have you tried `for cpu in (0..processorcount.to_i)` ? I''m wondering if it''s possible `processorcount` is a String. You might want to try using `<%= processorcount.inspect %>` to verify. BTW, other, more conventional options for doing this type of loop in Ruby would be: <% processorcount.to_i.times do |cpu| %> <% end %> or <% 0.upto(processorcount.to_i - 1) do |cpu| %> <% end %> Cheers, Bruce -- Bruce Williams Developer @ Reductive Labs, http://reductivelabs.com> On Mon, Nov 23, 2009 at 5:35 PM, Julian Simpson <simpsonjulian@gmail.com>wrote: > >> 2009/11/23 Christopher Johnston <chjohnst@gmail.com>: >> > Its definitely there.. I even put a <%= processorcount %> to make sure >> the >> > variable is set. >> > <% processorcount.to_i-1 %> >> > <% for cpu in (0..processorcount) %> >> > Facter version is 1.52 >> > # facter | grep proc >> > processor0 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz >> > processor1 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz >> > processor2 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz >> > processor3 => Intel(R) Xeon(R) CPU X5570 @ 2.93GHz >> > processorcount => 4 >> >> And the <%= processorcount %> snippet resolved to 4 in your template? >> >> I''m stumped then. I thought you could do iteration with any ERB >> template, not just in Rails. >> >> J. >> >> -- >> >> 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<puppet-users%2Bunsubscribe@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=. >> >> >> > -- > 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<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=. >-- 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.
Christopher Johnston wrote:> Yes it prints 4 directly into the file, but I cant put processorcount > into the loop. Works fine in ruby but erb fails. Any ideas here on how > to do this? I need to be able to determine the number of processors on > the systems so I can generate a configuration file (loop through each > processor number). >Try initializing it first. I know, annoying. Check this out: http://stackoverflow.com/questions/1338960/ruby-templates-how-to-pass-variables-into-inlined-erb -scott -- 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.
your problems is that processorcount is a string, here are some examples that works: <% processorcount.each do |cpu| -%> <%= cpu.to_i * 100 %> <%# more stuff -%> <% end %> <% for cpu in (0..processorcount.to_i) %> <%= cpu %> <%end%> <% processorcount.to_i.times do |cpu| %> <%= cpu %> <%end%> Ohad On Thu, Nov 19, 2009 at 11:22 PM, Christopher Johnston <chjohnst@gmail.com>wrote:> How come this doesnt work? I write this in a normal ruby script it > works just fine. > > <% for cpu in (0..processorcount) %> > > I want to loop through the number of processor so a specific action > can be taken to generate content for a file. I get an error on the > master of: > > bad value for range at /etc/puppet" > > -Chris > > -- > > 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<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=. > > >-- 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.
ah! I am still learning ruby here so appreciate the time spent to show me this. Shouldn''t this also work to subtract (1) from the integer? Works in a ruby script but not here. 19 <% processorcount.to_i - 1 %> 20 <% for cpu in (0..processorcount.to_i) %> On Mon, Nov 23, 2009 at 9:17 PM, Ohad Levy <ohadlevy@gmail.com> wrote:> your problems is that processorcount is a string, here are some examples > that works: > > <% processorcount.each do |cpu| -%> > <%= cpu.to_i * 100 %> > <%# more stuff -%> > <% end %> > > <% for cpu in (0..processorcount.to_i) %> > <%= cpu %> > <%end%> > > <% processorcount.to_i.times do |cpu| %> > <%= cpu %> > <%end%> > > Ohad > > > > On Thu, Nov 19, 2009 at 11:22 PM, Christopher Johnston <chjohnst@gmail.com > > wrote: > >> How come this doesnt work? I write this in a normal ruby script it >> works just fine. >> >> <% for cpu in (0..processorcount) %> >> >> I want to loop through the number of processor so a specific action >> can be taken to generate content for a file. I get an error on the >> master of: >> >> bad value for range at /etc/puppet" >> >> -Chris >> >> -- >> >> 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<puppet-users%2Bunsubscribe@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=. >> >> >> > -- > 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<puppet-users%2Bunsubscribe@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.
> ah! I am still learning ruby here so appreciate the time spent to show me > this. > > Shouldn''t this also work to subtract (1) from the integer? Works in a ruby > script but not here. > > 19 <% processorcount.to_i - 1 %> > 20 <% for cpu in (0..processorcount.to_i) %>you mean it still counts up to 20? because processorcount isn''t reduced. <% for cpu in (0..(processorcount.to_i-1)) %> or what do you mean with it doesn''t work? cheers pete -- 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.
Ignore me, I had a typo. I had put the parentheses around (0..(processorcount.to_i-1) but I forgot the closing '')'' -Chris On Wed, Nov 25, 2009 at 11:30 AM, Peter Meier <peter.meier@immerda.ch>wrote:> > ah! I am still learning ruby here so appreciate the time spent to show > me > > this. > > > > Shouldn''t this also work to subtract (1) from the integer? Works in a > ruby > > script but not here. > > > > 19 <% processorcount.to_i - 1 %> > > 20 <% for cpu in (0..processorcount.to_i) %> > > you mean it still counts up to 20? because processorcount isn''t reduced. > > <% for cpu in (0..(processorcount.to_i-1)) %> > > or what do you mean with it doesn''t work? > > cheers pete > > -- > > 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<puppet-users%2Bunsubscribe@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.