Puppet Class: yum_cron

Defined in:
manifests/init.pp

Summary

Manage yum-cron

Overview

Parameters:

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

    Defines the presence of ‘yum-cron`.

  • enable (Boolean) (defaults to: true)

    Boolean that defines the state of ‘yum-cron`.

  • download_updates (Boolean) (defaults to: true)

    Boolean that determines if updates should be automatically downloaded.

  • apply_updates (Boolean) (defaults to: false)

    Boolean that determines if updates should be automatically installed. If set to ‘true` then `download_updates` ignored.

  • upgrade_type (Enum['default','security']) (defaults to: 'default')

    The kind of updates to perform. Applies only to EL8, EL9.

  • reboot (Enum['never','when-changed','when-needed']) (defaults to: 'never')

    Determines when the system should reboot. Valid values:

    • ‘never’ (default) - does not reboot the system

    • ‘when-changed’ - triggers a reboot after any upgrade

    • ‘when-needed’ - triggers a reboot only when rebooting is necessary to apply changes

    Applies only to EL8 and EL9.

  • reboot_command (String) (defaults to: "shutdown -r +5 'Rebooting after applying package updates'")

    Command to execute for rebooting the system after applying updates. Default is “shutdown -r +5 ‘Rebooting after applying package updates’”. Applies only to EL8 and EL9.

  • debug_level (Pattern[/^(?:-)?[0-9]$/]) (defaults to: '-2')

    Sets debug level.

  • exclude_packages (Array) (defaults to: [])

    Packages to exclude from updates.

  • randomwait (Pattern[/^[0-9]+$/]) (defaults to: '360')

    Sets random wait time.

  • mailto (String) (defaults to: 'root')

    Address notified about updates.

  • systemname (String) (defaults to: $facts['networking']['fqdn'])

    Name of system used in notifications.

  • email_host (String) (defaults to: 'localhost')

    Host used to send email messages.

  • update_cmd (Yum_cron::Update_cmd) (defaults to: 'default')

    The kind of updates to use. Applies only to EL7. Valid values:

    • default = yum upgrade

    • security = yum –security upgrade

    • security-severity:Critical = yum –sec-severity=Critical upgrade

    • minimal = yum –bugfix upgrade-minimal

    • minimal-security = yum –security upgrade-minimal

    • minimal-security-severity:Critical = –sec-severity=Critical upgrade-minimal

  • update_messages (Enum['yes','no']) (defaults to: 'yes')

    Determines whether a message should be emitted when updates are available, downloaded, and applied. Applies only to EL7.

  • extra_configs (Hash) (defaults to: {})

    Hash that can be used to define additional configurations. Applies only to EL7, EL8, and EL9.

    For EL8 and EL9 the hash defines additonal ‘dnf_automatic_config` resources. For EL7 the hash defines additional `yum_cron_config` resources.

  • extra_hourly_configs (Hash) (defaults to: {})

    Hash that can be used to define additional hourly configurations. Applies only to EL7.

    For EL7 the hash defines additional ‘yum_cron_hourly_config` resources.

  • yum_autoupdate_ensure (Enum['undef', 'UNSET', 'absent', 'disabled']) (defaults to: 'disabled')

    Defines how to handle yum-autoupdate on Scientific Linux systems. Applies only to Scientific Linux. Valid values:

    • ‘disabled’ (default) - Sets ENABLED=‘false’ in /etc/sysconfig/yum-autoupdate.

    • ‘absent’ - Uninstall the yum-autoupdate package.

    • ‘undef’ or ‘UNSET’ - Leave yum-autoupdate unmanaged.

  • package_ensure (Optional[String]) (defaults to: undef)

    The ensure value passed to yum-cron package resource. When ‘undef`, the value passed to the package resources is based on this class’ ‘ensure` parameter value.

  • package_name (String)

    yum-cron package name. Default is based on OS version.

  • service_name (String)

    yum-cron service name. Default is based on OS version.

  • service_ensure (Optional[String]) (defaults to: undef)

    The ensure value passed to yum-cron service resource. When ‘undef`, the value passed to the service resources is based on this class’ ‘ensure` and `enable` parameter values.

  • service_enable (Optional[Boolean]) (defaults to: undef)

    The ensure value passed to yum-cron package resource. When ‘undef`, the value passed to the service resources is based on this class’ ‘ensure` and `enable` parameter values.

  • service_hasstatus (Boolean) (defaults to: true)

    Service hasstatus property.

  • service_hasrestart (Boolean) (defaults to: true)

    Service hasrestart property.

  • config_path (Stdlib::Absolutepath)

    Path to yum-cron configuration. Default is based on OS version.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'manifests/init.pp', line 89

class yum_cron (
  String $package_name,
  String $service_name,
  Stdlib::Absolutepath $config_path,
  Enum['present', 'absent'] $ensure = 'present',
  Boolean $enable = true,
  Boolean $download_updates = true,
  Boolean $apply_updates = false,
  # EL8 and EL9 only options
  Enum['default','security'] $upgrade_type = 'default',
  Enum['never','when-changed','when-needed'] $reboot = 'never',
  String $reboot_command = "shutdown -r +5 'Rebooting after applying package updates'",
  # EL8 and EL7 options
  Pattern[/^(?:-)?[0-9]$/] $debug_level = '-2',
  Pattern[/^[0-9]+$/] $randomwait = '360',
  Array $exclude_packages = [],
  String $mailto = 'root',
  String $systemname = $facts['networking']['fqdn'],
  String $email_host = 'localhost',
  # EL7 only options
  Yum_cron::Update_cmd $update_cmd = 'default',
  Enum['yes','no'] $update_messages = 'yes',
  # Misc configs
  Hash $extra_configs = {},
  Hash $extra_hourly_configs = {},
  # Scientific Linux configs
  Enum['undef', 'UNSET', 'absent', 'disabled'] $yum_autoupdate_ensure  = 'disabled',
  # Package, Service and Config params
  Optional[String] $package_ensure = undef,
  Optional[String] $service_ensure = undef,
  Optional[Boolean] $service_enable = undef,
  Boolean $service_hasstatus = true,
  Boolean $service_hasrestart = true,
) {
  case $ensure {
    'present': {
      $package_ensure_default   = 'present'
      if $enable {
        $service_ensure_default = 'running'
        $service_enable_default = true
        $config_notify          = Service['yum-cron']
      } else {
        $service_ensure_default = 'stopped'
        $service_enable_default = false
        $config_notify          = undef
      }
    }
    'absent': {
      $package_ensure_default = 'absent'
      $service_ensure_default = 'stopped'
      $service_enable_default = false
      $config_notify          = undef
    }
    default: {
      # Do nothing
    }
  }

  $package_ensure_real = pick($package_ensure, $package_ensure_default)
  $service_ensure_real = pick($service_ensure, $service_ensure_default)
  $service_enable_real = pick($service_enable, $service_enable_default)

  if $apply_updates {
    $apply_updates_str    = 'yes'
    $download_updates_str = 'yes'
    $check_only           = 'no'
    $download_only        = 'no'
  } else {
    $apply_updates_str  = 'no'
    $check_only         = 'yes'

    if $download_updates {
      $download_updates_str = 'yes'
      $download_only        = 'yes'
    } else {
      $download_updates_str = 'no'
      $download_only        = 'no'
    }
  }

  if empty($exclude_packages) {
    $exclude_packages_ensure = 'absent'
  } else {
    $exclude_packages_ensure = 'present'
  }

  contain yum_cron::install
  contain yum_cron::service

  Class['yum_cron::install']
  -> Class['yum_cron::service']

  if $ensure == 'present' {
    contain yum_cron::config
    Class['yum_cron::install']
    -> Class['yum_cron::config']
    -> Class['yum_cron::service']
  }
}