fix(system_baseline): do not report a pending package upgrade as drift in check mode #321

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

Problem

tasks/update.yml runs ansible.builtin.package with upgrade: true, autoremove: true and autoclean: true in one task, in check mode as well. In check mode the package manager reports changed as soon as any package is waiting for an upgrade, so a scheduled dry run (ansible-playbook --check) of a play that includes this role reports every host as changed whenever a package landed between two patch runs. The play then looks like configuration drift, but nothing in the role's own configuration differs. A consumer who alerts on changed from a weekly dry run gets a false alarm on most weeks.

Out of scope: the real run, and the system_baseline_update switch that skips the whole update flow.

Proposal

  • Do not run the upgrade in check mode (when: not ansible_check_mode on the upgrade). A pending update is not drift.
  • Keep autoremove and autoclean checked, in a separate task, so a dry run still shows leftover packages.
  • Say it in the README (Notes) and in a bugfixes or minor_changes fragment, whichever you prefer for a change in check-mode behaviour.

Acceptance criteria

  • In check mode the upgrade task is skipped and the play reports no change from it (a Molecule converge in check mode, or a --check run in side_effect.yml, with a pending upgrade available from the stub repository if the scenario has one; otherwise an assert that the task is skipped).
  • In a real run the upgrade still happens (the existing scenario's update tag, or a unit-level assert on the task conditions).
  • autoremove and autoclean still run, and are checked, in check mode.
  • ansible-test sanity, ansible-lint and yamllint are clean; README and changelog fragment updated.

Not verified

  • I have not run Kamino's role in check mode against a host with a pending upgrade. The behaviour above is what I see with the same module call in my own role: every host reported changed in a weekly dry run whenever a package was waiting.
  • Whether you want a dry run to show pending updates. If so, an opt-in variable instead of a skip would serve both.
  • The Molecule scenario skips the update tag (no privileged container), so the new behaviour may only be checkable by reading the task conditions.

Questions for the maintainer

  • Skip the upgrade in check mode, or make it a variable (default skip)?
  • Is a split into an upgrade task and an autoremove/autoclean task acceptable?

Assisted-by: Claude Code

## Problem `tasks/update.yml` runs `ansible.builtin.package` with `upgrade: true`, `autoremove: true` and `autoclean: true` in one task, in check mode as well. In check mode the package manager reports `changed` as soon as any package is waiting for an upgrade, so a scheduled dry run (`ansible-playbook --check`) of a play that includes this role reports every host as changed whenever a package landed between two patch runs. The play then looks like configuration drift, but nothing in the role's own configuration differs. A consumer who alerts on `changed` from a weekly dry run gets a false alarm on most weeks. Out of scope: the real run, and the `system_baseline_update` switch that skips the whole update flow. ## Proposal - Do not run the upgrade in check mode (`when: not ansible_check_mode` on the upgrade). A pending update is not drift. - Keep `autoremove` and `autoclean` checked, in a separate task, so a dry run still shows leftover packages. - Say it in the README (Notes) and in a `bugfixes` or `minor_changes` fragment, whichever you prefer for a change in check-mode behaviour. ## Acceptance criteria - [ ] In check mode the upgrade task is skipped and the play reports no change from it (a Molecule converge in check mode, or a `--check` run in `side_effect.yml`, with a pending upgrade available from the stub repository if the scenario has one; otherwise an assert that the task is skipped). - [ ] In a real run the upgrade still happens (the existing scenario's `update` tag, or a unit-level assert on the task conditions). - [ ] `autoremove` and `autoclean` still run, and are checked, in check mode. - [ ] `ansible-test sanity`, ansible-lint and yamllint are clean; README and changelog fragment updated. ## Not verified - I have not run Kamino's role in check mode against a host with a pending upgrade. The behaviour above is what I see with the same module call in my own role: every host reported `changed` in a weekly dry run whenever a package was waiting. - Whether you want a dry run to show pending updates. If so, an opt-in variable instead of a skip would serve both. - The Molecule scenario skips the `update` tag (no privileged container), so the new behaviour may only be checkable by reading the task conditions. ## Questions for the maintainer - Skip the upgrade in check mode, or make it a variable (default skip)? - Is a split into an `upgrade` task and an `autoremove`/`autoclean` task acceptable? Assisted-by: Claude Code
Dragonish added the Kind/Enhancement
Status
Ready for Human
labels 2026-11-23 17:30:43 +00:00
Dragonish added
Status
Ready for Agent
and removed
Status
Ready for Human
labels 2026-11-23 17:33:11 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#321