Testing unattended-upgrades on a staging VM without production credentials, and deciding the automatic reboot policy
0 reputation · 08 Feb 2023, 17:24 UTC
0 reputation · 08 Feb 2023, 17:24 UTC
I want to validate our unattended-upgrades configuration on a staging VM before rolling it out to production Ubuntu servers. The test should mirror production behavior as closely as possible, but the staging environment has no production credentials, no access to internal mirrors that require authentication, and no live mail relay.
The plan is to scope Unattended-Upgrade::Allowed-Origins in /etc/apt/apt.conf.d/50unattended-upgrades to the security pocket only, point Unattended-Upgrade::Mail at a local mailbox, and use Unattended-Upgrade::Package-Blacklist to hold back kernel packages during the trial. I would validate with unattended-upgrade --dry-run --debug and review /var/log/unattended-upgrades/ before enabling anything for real. Assume a recent Ubuntu LTS release.
The open question is reboot policy. Unattended-Upgrade::Automatic-Reboot defaults to false, and we have not decided whether to enable it with a fixed Automatic-Reboot-Time window, rely on Automatic-Reboot-WithUsers, or leave reboots manual and accept that some updates stay pending.
35275 reputation · 09 Feb 2023, 00:15 UTC
Running unattended-upgrade --dry-run --debug on a clean staging VM that mirrors the production Ubuntu LTS release is a reliable proxy for most upgrade-time decisions. It reproduces dependency resolution, package selection, and the log entries that would be written on a real run. However, it does not execute post-install scripts or detect runtime failures that only appear after packages are actually installed.
The Allowed-Origins filter and local mail reporting can be exercised entirely without external credentials; the mail sent by unattended-upgrades is delivered to the configured mailbox locally. Reboot behavior is governed by the three settings:
Automatic-Reboot – enables a reboot after a kernel or other reboot-required package is installed.Automatic-Reboot-Time – forces a reboot at the specified time window, regardless of logged-in users.Automatic-Reboot-WithUsers – defers the reboot until no users are logged in./etc/apt/apt.conf.d/50unattended-upgrades without needing external SMTP credentials./var/log/unattended-upgrades/unattended-upgrades.log contains the same information as the debug output./etc/apt/sources.list entries (no internal mirrors that require authentication).unattended-upgrades package if not already present.Unattended-Upgrade::Allowed-Origins to "${distro_id}:${distro_codename}-security".Unattended-Upgrade::Mail to a local mailbox (e.g., root or a dedicated user).Unattended-Upgrade::Package-Blacklist with "linux-image-*" to hold back kernels.Automatic-Reboot disabled for the dry-run phase.sudo unattended-upgrade --dry-run --debug | tee /tmp/ur-dryrun.log
/var/log/unattended-upgrades/unattended-upgrades.log.Automatic-Reboot to true and choose a policy that matches your maintenance window strategy.Automatic-Reboot-WithUsers if you prefer to avoid reboots while users are logged in.sudo unattended-upgrade and watch for the system to reboot at the configured time or after all users log out.Automatic-Reboot with a fixed time window.Automatic-Reboot-WithUsers helps avoid disrupting logged-in sessions.Automatic-Reboot-Time to guarantee a reboot at that slot.Does production use any custom kernel packages or services that are absent from the staging VM?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.