Works for me: kbarber:~ ken$ cat template.erb $restricted <%= fqdn %> $ideal_load <%= num_cpu.to_i + 0.5 %> $max_load <%= num_cpu.to_i * 1.2 %> kbarber:~ ken$ cat template.pp $num_cpu = 5 notice(template("/Users/ken/template.erb")) kbarber:~ ken$ puppet apply -v template.pp notice: Scope(Class[main]): $restricted kbarber.lan $ideal_load 5.5 $max_load 6.0
info: Applying configuration version '1308143319' notice: Finished catalog run in 0.01 seconds kbarber:~ ken$ Can you copy my example exactly and see what happens? Otherwise sounds like a versioning thing - what version of puppet/ruby are you running? ken. On Wed, Jun 15, 2011 at 2:05 PM, Sans <r.santanu....@gmail.com> wrote: > Hi Ken, > > I did that as you said and on the client I get the file with: > > > $restricted myserv.ac.uk > $ideal_load 8 + 0.5 > $max_load 8 * 1.2 > > where num_cpu = 8. But if put: > > $i_load = $num_cpu + 0.5 > $m_load = $num_cpu * 1.2 > > in the "init.pp" and then "$ideal_load <%= i_load %>" (same for the > $max_load) in the template file, it works. > Any idea what's wrong? Cheers!! > > On Jun 15, 1:51 pm, Ken Barber <k...@puppetlabs.com> wrote: >> Your template file should look something like: >> >> $restricted <%= fqdn %> >> $ideal_load <%= num_cpu.to_i + 0.5 %> >> $max_load <%= num_cpu.to_i * 1.2 %> >> >> (the to_i is to ensure the conversion to integer - as I'm not sure >> what the input data looks like :-) >> >> Read the docs to get the full picture: >> >> http://docs.puppetlabs.com/guides/templating.html >> >> ken. >> >> On Wed, Jun 15, 2011 at 12:22 PM, Sans <r.santanu....@gmail.com> wrote: >> > I've added a custom fact, namely "num_cpu", to Facter and >> > pluginsync'ing to distribute to the clients. Now I want to write a >> > template (as the num_cpu differs from client to client) file, which >> > will generate a file like this, in return: >> >> > $restricted myserv.ac.uk >> > $ideal_load 8.5 >> > $max_load 9.6 >> >> > for values for $ideal_load and $max_load are calculated like this: >> > "num_cpu + 0.5" and "num_cpu * 1.2" respectively. Can anyone give me >> > some idea how should I do that please? Cheers!! >> >> > -- >> > 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+unsubscr...@googlegroups.com. >> > For more options, visit this group >> > athttp://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+unsubscr...@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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.