virtual resources vs fqdn_rand

39 views
Skip to first unread message

Adam Heinz

unread,
Mar 22, 2012, 11:35:41 AM3/22/12
to puppet...@googlegroups.com
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!

Krzysztof Wilczynski

unread,
Mar 22, 2012, 12:29:45 PM3/22/12
to puppet...@googlegroups.com
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
 
Reply all
Reply to author
Forward
0 new messages