Hello I.m trying to get a ''static random'' base on a node''s ip address and use that number as the minute for a crontab so each node will get a number between and 59 The things is the number is generated by the puppet master and so all node get the same value... my current code : random_minute = generate(''/usr/bin/env'', ''bash'', ''-c'', ''host `uname -n` | head -1 | awk \''{ print $4 }\'' | awk -F . \''{ printf("%d\n", ($1+$2+$3+$4)%60); }\'''') So Im a lost what do i need to do so ''generate'' used the node''s IP and not puppetmaster... Thanks! -ls -- 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.
Luc Suryo said:> Hello > > I.m trying to get a ''static random'' base on a node''s ip address and > use that number as the minute for a crontab > so each node will get a number between and 59 > > The things is the number is generated by the puppet master and so all > node get the same value... > > my current code : > > random_minute = generate(''/usr/bin/env'', ''bash'', ''-c'', ''host `uname > -n` | head -1 | awk \''{ print $4 }\'' | awk -F . \''{ printf("%d\n", > ($1+$2+$3+$4)%60); }\'''') > > > So Im a lost what do i need to do so ''generate'' used the node''s IP and > not puppetmaster... > >Did you perhaps want the fqdn_rand() function? This gives a "static random" number based on the node''s fqdn (not IP like you asked for, but hopefully usable anyway). I use it like this: $minute1 = fqdn_rand(15) $minute2 = 15+$minute1 $minute3 = 30+$minute1 $minute4 = 45+$minute1 cron { "run puppet": command => $puppetrun, user => root, minute => [ $minute1, $minute2, $minute3, $minute4 ], require => File[$sysadmindir], } (from https://gitorious.org/qtqa/sysadmin/blobs/master/puppet/modules/puppet/manifests/unix.pp ) Only think I can''t remember is if it returns an integer from 0 .. 14 or 0 .. 15 :) -- Rohan McGovern Quality Engineer Qt Development Frameworks, Nokia -- 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.
I end up doing this: http://projects.puppetlabs.com/projects/1/wiki/Writing_Your_Own_Functions and works well, I was hoping not to have to write a function, but then realized I need to get node''s facter ipaddress, add the 4 of the octet and a % 60 and we are set :-) but thanks for the tip, added to my bookmark :) On Tue, Apr 19, 2011 at 6:06 PM, Rohan McGovern <rohan.mcgovern@nokia.com> wrote:> Luc Suryo said: >> Hello >> >> I.m trying to get a ''static random'' base on a node''s ip address and >> use that number as the minute for a crontab >> so each node will get a number between and 59 >> >> The things is the number is generated by the puppet master and so all >> node get the same value... >> >> my current code : >> >> random_minute = generate(''/usr/bin/env'', ''bash'', ''-c'', ''host `uname >> -n` | head -1 | awk \''{ print $4 }\'' | awk -F . \''{ printf("%d\n", >> ($1+$2+$3+$4)%60); }\'''') >> >> >> So Im a lost what do i need to do so ''generate'' used the node''s IP and >> not puppetmaster... >> >> > > Did you perhaps want the fqdn_rand() function? > > This gives a "static random" number based on the node''s fqdn (not IP > like you asked for, but hopefully usable anyway). > > I use it like this: > > $minute1 = fqdn_rand(15) > $minute2 = 15+$minute1 > $minute3 = 30+$minute1 > $minute4 = 45+$minute1 > > cron { "run puppet": > command => $puppetrun, > user => root, > minute => [ $minute1, $minute2, $minute3, $minute4 ], > require => File[$sysadmindir], > } > > (from https://gitorious.org/qtqa/sysadmin/blobs/master/puppet/modules/puppet/manifests/unix.pp ) > > Only think I can''t remember is if it returns an integer from 0 .. 14 or 0 .. 15 :) > -- > Rohan McGovern > Quality Engineer > Qt Development Frameworks, Nokia >-- -ls -- 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.