Puppet Class: patching_as_code::linux::patchday
- Defined in:
- manifests/linux/patchday.pp
Summary
This class gets called by init.pp to perform the actual patching on Linux.Overview
Class: patching_as_code::linux::patchday
13 14 15 16 17 18 19 20 21 22 23 24 25 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 69 70 71 72 73 74 75 |
# File 'manifests/linux/patchday.pp', line 13
class patching_as_code::linux::patchday (
Array $updates,
Array $choco_updates = [],
Array $high_prio_updates = [],
Array $high_prio_choco_updates = []
) {
case $facts['package_provider'] {
'yum': {
$cmd = 'yum clean all'
$cmd_path = '/usr/bin'
}
'dnf': {
$cmd = 'dnf clean all'
$cmd_path = '/usr/bin'
}
'apt': {
$cmd = 'apt-get clean'
$cmd_path = '/usr/bin'
}
'zypper': {
$cmd = 'zypper cc --all'
$cmd_path = '/usr/bin'
}
default: {
$cmd = 'true'
$cmd_path = '/usr/bin'
}
}
if $updates.count > 0 {
exec { 'Patching as Code - Clean Cache': # lint:ignore:exec_idempotency
command => $cmd,
path => $cmd_path,
schedule => 'Patching as Code - Patch Window',
}
$updates.each | $package | {
patch_package { $package:
patch_window => 'Patching as Code - Patch Window',
chocolatey => false,
require => Exec['Patching as Code - Clean Cache'],
}
}
}
if $high_prio_updates.count > 0 {
exec { 'Patching as Code - Clean Cache (High Priority)': # lint:ignore:exec_idempotency
command => $cmd,
path => $cmd_path,
schedule => 'Patching as Code - High Priority Patch Window',
}
$high_prio_updates.each | $package | {
patch_package { $package:
patch_window => 'Patching as Code - High Priority Patch Window',
chocolatey => false,
require => Exec['Patching as Code - Clean Cache (High Priority)'],
}
}
}
anchor { 'patching_as_code::patchday::end': } #lint:ignore:anchor_resource
}
|