Hi, I would like to have puppet manage a file on each client. The file is the same for all clients, but has two random numbers in it. I assume I can use something like fqdn_rand(0-59) to generate a random number between 0 and 59, right? My main question is how to I get puppet to not think the file is different every time puppetd runs? Would I use a template or a file def and contents? --- Thanks, Allan Marcus 505-667-5666 --~--~---------~--~----~------------~-------~--~----~ 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> I would like to have puppet manage a file on each client. The file is > the same for all clients, but has two random numbers in it. > > I assume I can use something like fqdn_rand(0-59) to generate a random > number between 0 and 59, right? > > My main question is how to I get puppet to not think the file is > different every time puppetd runs? Would I use a template or a file > def and contents?neither will help. either you make your random function depending on a seed, which means it isn''t really random anymore. Or if you create the file, replace => false might be your friend. But then for sure if you change your other content it won''t adjust them as well. 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 -~----------~----~----~----~------~----~------~--~---
Depending on how you are doing it, you could use: exec "randno" { creates => "/tmp/foo", } Let me guess, you are trying to get cron to run at a random but consistent time, yes? From what I''ve read (haven''t tried it myself yet) the best way is to map the number from a consistent thing about the host... Maybe get the last octet from the IP address of the node and do an IP % 60 perhaps... Its not random, but it does spread out a cron job over the hour... Since its on my todo list as well, I haven''t got an example of exactly how to do this to show you unfortunately... Greg On Aug 12, 8:03 am, Peter Meier <peter.me...@immerda.ch> wrote:> Hi > > > I would like to have puppet manage a file on each client. The file is > > the same for all clients, but has two random numbers in it. > > > I assume I can use something like fqdn_rand(0-59) to generate a random > > number between 0 and 59, right? > > > My main question is how to I get puppet to not think the file is > > different every time puppetd runs? Would I use a template or a file > > def and contents? > > neither will help. either you make your random function depending on a > seed, which means it isn''t really random anymore. Or if you create the > file, replace => false might be your friend. But then for sure if you > change your other content it won''t adjust them as well. > > 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 -~----------~----~----~----~------~----~------~--~---
Here is one method to perform puppet runs via cron: http://reductivelabs.com/trac/puppet/wiki/Recipes/cron It also allows you to manually tweak the times each node runs. -L -- Larry Ludwig Reductive Labs --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks to all of you for your help. This cron example is close to where I was heading. Macs can use cron, but it''s not encouraged, so I will convert the concept to launchd. --- Thanks, Allan Marcus 505-667-5666 On Aug 11, 2009, at 9:02 PM, Larry Ludwig wrote:> > Here is one method to perform puppet runs via cron: > > http://reductivelabs.com/trac/puppet/wiki/Recipes/cron > > It also allows you to manually tweak the times each node runs. > > -L > > -- > Larry Ludwig > Reductive Labs > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Tue, 2009-08-11 at 13:07 -0600, Allan Marcus wrote:> Hi, > > I would like to have puppet manage a file on each client. The file is > the same for all clients, but has two random numbers in it. > > I assume I can use something like fqdn_rand(0-59) to generate a random > number between 0 and 59, right?Right. But with a caveat: the random number is not really random. In fact the random generator is seeded with the node fqdn. Since this is a constant, the generated random number won''t change from run to run for a given node.> My main question is how to I get puppet to not think the file is > different every time puppetd runs? Would I use a template or a file > def and contents?file { "/path/to/random": content => fqdn_rand(60) } Will produce a file containing a random number that will never change for a given node. Or if you want to manage cron resource directly: cron { "mycron": command => "/usr/local/bin/backup-logical", hour => ''*'', minute => fqdn_rand(60), } Hope that helps, -- Brice Figureau My Blog: http://www.masterzen.fr/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---