Puppet Class: cron

Defined in:
manifests/init.pp

Overview

Main entry point into all cron-related resources on the host. It purges by default. You've been warned!

Examples:

Declaring the cron class

include cron

Also purge unmanaged files in /etc/cron.d directory

class { 'cron':
  purge_crond => true,
}

Removing all cron-related resources from the system

class { 'cron':
  ensure => absent,
}

Deny crontab(1) usage to all users except 'luke' (and 'root' - he can always do that).

class { 'cron':
  allowed_users => [ 'luke' ],
}

Parameters:

  • ensure (Enum[present, absent]) (defaults to: present)

    Whether to enable or disable cron on the system.

  • package_version (Pattern[/\A[^\n]+\z/]) (defaults to: installed)

    Custom cron package version.

  • allow_all_users (Boolean) (defaults to: false)

    Allow all users to manage crontab.

  • allowed_users (Array[Cron::User]) (defaults to: [ ])

    List of users allowed to use crontab(1). By default, only root can.

  • denied_users (Array[Cron::User]) (defaults to: [ ])

    List of users specifically denied to use crontab(1). Note: When this is not empty, all users except ones specified here will be able to use crontab.

  • service_manage (Boolean) (defaults to: true)

    Whether to manage cron service at all.

  • service_ensure (Enum[running, stopped]) (defaults to: running)

    Cron service's ensure parameter.

  • service_enable (Boolean) (defaults to: true)

    Cron service's enable parameter.

  • purge_cron (Boolean) (defaults to: true)

    Whether to purge crontab entries.

  • purge_crond (Boolean) (defaults to: false)

    Also purge unmanaged files in /etc/cron.d directory.

  • purge_noop (Boolean) (defaults to: false)

    Run purging in noop mode.

See Also:

  • crontab(1), crontab(5), cron(8)


37
38
39
40
41
42
43
44
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
# File 'manifests/init.pp', line 37

class cron (
  Enum[present, absent]  $ensure          = present,

  # cron::install
  Pattern[/\A[^\n]+\z/]  $package_version = installed,

  # cron::config
  Boolean                $allow_all_users = false,
  Array[Cron::User]      $allowed_users   = [ ],
  Array[Cron::User]      $denied_users    = [ ],

  # cron::service
  Boolean                $service_manage  = true,
  Enum[running, stopped] $service_ensure  = running,
  Boolean                $service_enable  = true,

  # cron::purge
  Boolean                $purge_cron      = true,
  Boolean                $purge_crond     = false,
  Boolean                $purge_noop      = false,
) {

  if $ensure == present {

    contain cron::install
    contain cron::config
    contain cron::service

    contain cron::purge

    Class['::cron::install'] -> Class['::cron::service'] -> Class['::cron::purge']
    Class['::cron::install'] ~> Class['::cron::service']

  } else {

    contain cron::remove

  }

}