Defined Type: cron::job

Defined in:
manifests/job.pp

Overview

Type: cron::job

This type creates a cron job via a file in /etc/cron.d

Parameters:

ensure - The state to ensure this resource exists in. Can be absent, present
  Defaults to 'present'
minute - The minute the cron job should fire on. Can be any valid cron
minute value.
  Defaults to '*'.
hour - The hour the cron job should fire on. Can be any valid cron hour
value.
  Defaults to '*'.
date - The date the cron job should fire on. Can be any valid cron date
value.
  Defaults to '*'.
month - The month the cron job should fire on. Can be any valid cron month
value.
  Defaults to '*'.
weekday - The day of the week the cron job should fire on. Can be any valid
cron weekday value.
  Defaults to '*'.
environment - An array of environment variable settings.
  Defaults to an empty set ([]).
mode - The mode to set on the created job file
  Defaults to 0644.
user - The user the cron job should be executed as.
  Defaults to 'root'.
description - Optional short description, which will be included in the
cron job file.
  Defaults to undef.
command - The command to execute.

Actions:

Requires:

Sample Usage:

cron::job { 'generate_puppetdoc':
  minute      => '01',
  environment => [ 'PATH="/usr/sbin:/usr/bin:/sbin:/bin"' ],
  command     => 'puppet doc /etc/puppet/modules >/var/www/puppet_docs.mkd',
}

Parameters:

  • command (Optional[String[1]]) (defaults to: undef)
  • ensure (Cron::Job_ensure) (defaults to: 'present')
  • minute (Cron::Minute) (defaults to: '*')
  • hour (Cron::Hour) (defaults to: '*')
  • date (Cron::Date) (defaults to: '*')
  • month (Cron::Month) (defaults to: '*')
  • weekday (Cron::Weekday) (defaults to: '*')
  • special (Cron::Special) (defaults to: undef)
  • environment (Cron::Environment) (defaults to: [])
  • user (Cron::User) (defaults to: 'root')
  • mode (Cron::Mode) (defaults to: '0644')
  • description (Optional[String]) (defaults to: undef)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'manifests/job.pp', line 45

define cron::job (
  Optional[String[1]] $command     = undef,
  Cron::Job_ensure    $ensure      = 'present',
  Cron::Minute        $minute      = '*',
  Cron::Hour          $hour        = '*',
  Cron::Date          $date        = '*',
  Cron::Month         $month       = '*',
  Cron::Weekday       $weekday     = '*',
  Cron::Special       $special     = undef,
  Cron::Environment   $environment = [],
  Cron::User          $user        = 'root',
  Cron::Mode          $mode        = '0644',
  Optional[String]    $description = undef,
) {

  assert_type(Cron::Jobname, $title)

  case $ensure {
    'absent':  {
      file { "job_${title}":
        ensure => 'absent',
        path   => "/etc/cron.d/${title}",
      }
    }
    default: {
      file { "job_${title}":
        ensure  => 'file',
        owner   => 'root',
        group   => 'root',
        mode    => $mode,
        path    => "/etc/cron.d/${title}",
        content => template('cron/job.erb'),
      }
    }
  }
}