Running puppet-2.6.13-2.el6.noarch on CentOS 6. define backup($apphost, $appfqdn) { cron { "backup-${apphost}-daily": command => "/usr/bin/rsync -a $appfqdn:backups/ $backdir/daily --delete", hour => "2", minute => fqdn_rand(60), } } then elsewhere @@backup { $::hostname: appfqdn => $::fqdn, apphost => $::hostname, } Easy enough, or so I thought. Some time after I initially wrote this, I investigated some I/O spikes and sure enough, all of my backups are running at the same minute -- the fqdn_rand is being calculated for the backup server, not for the slaves being backed up. I have worked around this by passing in a $minute argument, but this seems a bit inelegant -- the slave certainly has no business determining the backup schedule. Other than a feature request for fqdn_rand to allow a value to be passed in, any ideas on a more elegant way to accomplish this? Criticism welcome! -- 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.
Krzysztof Wilczynski
2012-Mar-22 16:29 UTC
[Puppet Users] Re: virtual resources vs fqdn_rand
Hi, [...]> I have worked around this by passing in a $minute argument, but this > seems a bit inelegant -- the slave certainly has no business > determining the backup schedule. Other than a feature request for > fqdn_rand to allow a value to be passed in, any ideas on a more > elegant way to accomplish this? Criticism welcome! >I did this quickly for you: https://gist.github.com/2159360 kwilczynski@lamhirh ~/Sandbox $ RUBYLIB=. cat - | puppet 2> /dev/null notice random_crontab_minutes(''rsync'', $hostname) notice random_crontab_minutes(''abc'', ''def'') notice: Scope(Class[main]): 10 notice: Scope(Class[main]): 6 notice: Finished catalog run in 0.03 seconds I am not sure if this will help / fit you use case, have a look :) KW -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/N-MA3hfkezUJ. 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.