Skip to content

Instantly share code, notes, and snippets.

@JonathonAnderson
Created September 16, 2021 18:35
Show Gist options
  • Save JonathonAnderson/59af1753ae7b41f9fc32ce372a2555a0 to your computer and use it in GitHub Desktop.
Save JonathonAnderson/59af1753ae7b41f9fc32ce372a2555a0 to your computer and use it in GitHub Desktop.
# Check for pending reboots before attempting to update
reboot { 'pre_patch_reboot':
schedule => 'patch_window',
when => 'pending',
message => 'Reboot pending. Rebooting before attempting updates...',
}
Reboot['pre_patch_reboot'] -> Reboot['post_patch_reboot']
# Apply allowed/needed updates
$updates.each | $kb | {
windows_updates::kb { $kb:
ensure => 'present',
maintwindow => 'patch_window',
}
Reboot['pre_patch_reboot'] -> Windows_Updates::Kb[$kb] -> Reboot['post_patch_reboot']
}
# Reboot after updates if needed
reboot { 'post_patch_reboot':
schedule => 'patch_window',
when => 'pending',
message => 'Updates Installed. Rebooting.',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment