feat(system_baseline): add a per-host package blacklist for unattended-upgrades #322

Closed
opened 2026-11-23 17:30:44 +00:00 by Dragonish · 0 comments
Collaborator

Problem

system_baseline can pin the origins unattended-upgrades may install from (system_baseline_unattended_upgrade_origins), but it has no way to keep individual packages out of unattended-upgrades. A host whose kernel and driver combination must not change (for example one with hardware passthrough, or a pinned kernel) has to be patched without those packages, and today the consumer has to write Unattended-Upgrade::Package-Blacklist into /etc/apt/apt.conf.d/ by hand. system_baseline_unattended_upgrade_settings writes one key "value"; line per entry, which cannot express the list form that Package-Blacklist takes (Package-Blacklist { "a"; "b"; };).

Out of scope: the origins pin, and the apt upgrade done by the role's own update flow (a separate matter).

Proposal

  • New variable system_baseline_unattended_upgrade_package_blacklist (list of strings, default []). A non-empty list is written to a block in /etc/apt/apt.conf.d/50unattended-upgrades (or a drop-in of its own, your choice) as Unattended-Upgrade::Package-Blacklist { "<pkg>"; ... };, with a marker so the block can be rewritten. Entries are regular expressions in unattended-upgrades, so the README says that.
  • Entries may not hold a double quote, a backslash or a line break (the same rule as the origins).
  • An empty list removes the block. Add it to meta/argument_specs.yml and the README variable table, and a minor_changes fragment.

Acceptance criteria

  • With a two-entry blacklist, apt-config dump in verify.yml shows both under Unattended-Upgrade::Package-Blacklist.
  • With an empty list the block is absent after a run that had it before (a second converge or a side_effect.yml run).
  • An entry with a double quote, backslash or line break is refused by argument_specs or a validation task, with a message that names the variable.
  • A second run changes nothing (Molecule idempotence).
  • ansible-test sanity, ansible-lint and yamllint are clean; README and changelog fragment updated.

Not verified

  • The exact rendering in your role: I have this as a blockinfile in my own role and it works there, but I have not written it against your task layout.
  • Whether unattended-upgrades --dry-run --debug (your validation task) accepts the block on Ubuntu 24.04. It does in my role.

Questions for the maintainer

  • A block in 50unattended-upgrades, or a separate drop-in like the origins file?
  • Is the variable name right?

Assisted-by: Claude Code

## Problem `system_baseline` can pin the origins unattended-upgrades may install from (`system_baseline_unattended_upgrade_origins`), but it has no way to keep individual packages out of unattended-upgrades. A host whose kernel and driver combination must not change (for example one with hardware passthrough, or a pinned kernel) has to be patched without those packages, and today the consumer has to write `Unattended-Upgrade::Package-Blacklist` into `/etc/apt/apt.conf.d/` by hand. `system_baseline_unattended_upgrade_settings` writes one `key "value";` line per entry, which cannot express the list form that `Package-Blacklist` takes (`Package-Blacklist { "a"; "b"; };`). Out of scope: the origins pin, and the apt upgrade done by the role's own `update` flow (a separate matter). ## Proposal - New variable `system_baseline_unattended_upgrade_package_blacklist` (list of strings, default `[]`). A non-empty list is written to a block in `/etc/apt/apt.conf.d/50unattended-upgrades` (or a drop-in of its own, your choice) as `Unattended-Upgrade::Package-Blacklist { "<pkg>"; ... };`, with a marker so the block can be rewritten. Entries are regular expressions in unattended-upgrades, so the README says that. - Entries may not hold a double quote, a backslash or a line break (the same rule as the origins). - An empty list removes the block. Add it to `meta/argument_specs.yml` and the README variable table, and a `minor_changes` fragment. ## Acceptance criteria - [ ] With a two-entry blacklist, `apt-config dump` in `verify.yml` shows both under `Unattended-Upgrade::Package-Blacklist`. - [ ] With an empty list the block is absent after a run that had it before (a second converge or a `side_effect.yml` run). - [ ] An entry with a double quote, backslash or line break is refused by `argument_specs` or a validation task, with a message that names the variable. - [ ] A second run changes nothing (Molecule idempotence). - [ ] `ansible-test sanity`, ansible-lint and yamllint are clean; README and changelog fragment updated. ## Not verified - The exact rendering in your role: I have this as a `blockinfile` in my own role and it works there, but I have not written it against your task layout. - Whether `unattended-upgrades --dry-run --debug` (your validation task) accepts the block on Ubuntu 24.04. It does in my role. ## Questions for the maintainer - A block in `50unattended-upgrades`, or a separate drop-in like the origins file? - Is the variable name right? Assisted-by: Claude Code
Dragonish added the Kind/Enhancement
Status
Ready for Human
labels 2026-11-23 17:30:44 +00:00
Dragonish added
Status
Ready for Agent
and removed
Status
Ready for Human
labels 2026-11-23 17:32:53 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#322