Management of /etc/crontab
johanfleury opened this issue · comments
Hi.
I was wondering if you would accept a PR bringing /etc/crontab
management (on Debian) in this module?
For example I currently do something like this:
# Class: profile::base::cron
class profile::base::cron {
include ::cron
$crontab_environment = lookup(
'cron::crontab_environment', Array[String], undef,
[
'SHELL="/bin/sh"',
'PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"',
]
)
$crontab_hourly_time = lookup(
'cron::crontab_hourly_time', Integer[0,59], undef,
fqdn_rand(60, 'crontab hourly')
)
$crontab_daily_time = lookup(
'cron::crontab_daily_time', Integer[0,59], undef,
fqdn_rand(60, 'crontab daily')
)
$crontab_weekly_time = lookup(
'cron::crontab_weekly_time', Integer[0,59], undef,
fqdn_rand(60, 'crontab weekly')
)
$crontab_monthly_time = lookup(
'cron::crontab_monthly_time', Integer[0,59], undef,
fqdn_rand(60, 'crontab monthly')
)
file { '/etc/crontab':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => template('profile/base/cron/crontab.erb'),
require => Class['::cron'],
}
}
# This file is managed by Puppet. DO NOT EDIT.
<%- if not @crontab_environment.nil? -%>
<%- @crontab_environment.each do |env| -%>
<%= env %>
<%- end -%>
<%- end -%>
<%= @crontab_hourly_time %> * * * * root cd / && run-parts --report /etc/cron.hourly
<%= @crontab_daily_time %> 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
<%= @crontab_weekly_time %> 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
<%= @crontab_monthly_time %> 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
Please let me know if this is something that you could accept (of course I would make this more generic).
Anyway your module is great!
Hi,
I thought about doing this also a while ago but I don't think it's a good idea for this module.
It will certainly break jobs for users that configured some in /etc/crontab
through whatever means.
It will also add a bunch of complexity (e.g. Debian vs. RHEL distributions).
I think this module should only focus on handling cronjobs in /etc/cron.d
.
But I do think it makes sense to also handle your use case in Puppet.
Maybe create a separate small module which only handles /etc/crontab
?
I think that would make sense.