Puppet Class: psick::update

Defined in:
manifests/update.pp

Overview

This class managed system’s packages updates via cron

Parameters:

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

    The cron schedule to use for System Updates. If not set no automatic update is done (unless use_yum_cron is true)

  • update_template (String) (defaults to: 'psick/update/update.sh.erb')

    The erb template to use for the update_script_path

  • update_script_path (String) (defaults to: '/usr/local/sbin/update.sh')

    The path of the script used for system updates

  • use_yum_cron (Boolean) (defaults to: false)

    If to install (only on RedHat derivatives) the yum_cron package (via the ::psick::yum::cron class). If true, the other options are ignored.

  • manage (Boolean) (defaults to: $psick::manage)

    If to actually manage any resource in this class. If false no resource is managed. Default value is taken from main psick class.

  • noop_manage (Boolean) (defaults to: $psick::noop_manage)

    If to use the noop() function for all the resources provided by this class. If this is true the noop function is called with $noop_value argument. This overrides any other noop setting (either set on client’s puppet.conf or by noop() function in main psick class). Default from psick class.

  • noop_value (Boolean) (defaults to: $psick::noop_value)

    The value to pass to noop() function if noop_manage is true. It applies to all the resources (and classes) declared in this class If true: noop metaparamenter is set to true, resources are not applied If false: noop metaparameter is set to false, and any eventual noop setting is overridden: resources are always applied. Default from psick class.

  • reboot_after_update (Boolean) (defaults to: false)


26
27
28
29
30
31
32
33
34
35
36
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
# File 'manifests/update.pp', line 26

class psick::update (
  Optional[String] $cron_schedule = undef,
  Boolean $reboot_after_update = false,
  String $update_template      = 'psick/update/update.sh.erb',
  String $update_script_path   = '/usr/local/sbin/update.sh',
  Boolean $use_yum_cron        = false,

  Boolean          $manage               = $psick::manage,
  Boolean          $noop_manage          = $psick::noop_manage,
  Boolean          $noop_value           = $psick::noop_value,

) {
  if $manage {
    if $noop_manage {
      noop($noop_value)
    }
    if $facts['os']['family'] == 'RedHat' and $use_yum_cron {
      contain psick::yum::cron
      file { '/etc/cron.d/system_update':
        ensure  => absent,
      }
    } else {
      # Custom update script
      if $cron_schedule {
        file { '/etc/cron.d/system_update':
          ensure  => file,
          content => "# File managed by Puppet\n${cron_schedule} root ${update_script_path}\n",
        }
      } else {
        file { '/etc/cron.d/system_update':
          ensure  => absent,
        }
      }

      file { $update_script_path:
        ensure  => file,
        mode    => '0750',
        content => template($update_template),
        before  => File['/etc/cron.d/system_update'],
      }
    }
  }
}