ReleaseEngineering/PuppetAgain/Modules/needs reboot

From MozillaWiki
Jump to: navigation, search

Hosts - even UNIX - often need to be rebooted to get certain updates. For example, to perform a kernel upgrade or boot-time configuration parameter.

It would be bad if puppet did this on its own. Very bad. Humans should do the rebooting, but puppet should let them know which machines need it. That's where this module comes in

Reasons

The structure of this module is that a reboot might be required for any of a variety of reasons. Each reason for a reboot has a short name and is detected by a small ruby script.

Adding New Reasons

To add a new reason, add a new file in modules/needs_reboot/lib/facter/needs_reboot/my_reason.rb, with the following pattern:

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

require 'facter/needs_reboot'

Facter::NeedsReboot.newreason("my_reason") do
  true # return a boolean
end

This will be pluginsync'd and used to determine the relevant facts automatically.

Facts

Each reason has a corresponding needs_reboot_for_${name}, which is true if that reason applies.

The needs_reboot fact is a human-readable list of all reasons that a reboot is required.

Any of these facts can be used in a dashboard to search for hosts needing a reboot.

MOTD

The module also adds a line to the system MOTD when a reboot is required. This will indicate to users accessing the system that a reboot would be handy, helping to take advantage of opportunities.