Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ Cron. Minute of the hour to schedule the cron entry

Default: 10

#####`cron_email`

Cron. Set the email address MAILTO field for the errors from the cron job

Default: undef

### Private classes

Expand Down
18 changes: 13 additions & 5 deletions manifests/job.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
$cron_weekday = '*',
$cron_hour = 1,
$cron_minute = 10,
$cron_email = undef,
){

include ::curator
Expand Down Expand Up @@ -280,15 +281,22 @@
$auth_string = undef
}

if $cron_email {
$cron_environment = "MAILTO=${cron_email}"
} else {
$cron_environment = undef
}

$index_options = join(delete_undef_values([$_prefix, $_suffix, $_regex, $_time_unit, $_exclude, $_index, $_snapshot, $_older_than, $_newer_than, $_timestring]), ' ')
$options = join(delete_undef_values([$mo_string, $ssl_string, $ssl_certificate, $ssl_no_validate, $auth_string]), ' ')

cron { "curator_${name}":
ensure => $ensure,
command => "${bin_file} --logfile ${logfile} --loglevel ${log_level} --logformat ${logformat} ${options} --host ${host} --port ${port} ${exec} ${index_options} >/dev/null",
hour => $cron_hour,
minute => $cron_minute,
weekday => $cron_weekday,
ensure => $ensure,
command => "${bin_file} --logfile ${logfile} --loglevel ${log_level} --logformat ${logformat} ${options} --host ${host} --port ${port} ${exec} ${index_options} >/dev/null",
hour => $cron_hour,
minute => $cron_minute,
weekday => $cron_weekday,
environment => $cron_environment,
}

}
10 changes: 10 additions & 0 deletions spec/defines/curator_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@
end
end

context 'not setting email' do
let (:params) {{:command => 'snapshot', :repository => 'archive'}}
it { should contain_cron('curator_myjob').with(:environment => nil)}
end

context 'setting email' do
let (:params) {{:command => 'snapshot', :repository => 'archive', :cron_email => 'admin@example.com'}}
it { should contain_cron('curator_myjob').with(:environment => 'MAILTO=admin@example.com')}
end

context 'set all other params' do
let(:params) do
{
Expand Down