Files
Kamino/roles/system_baseline/tasks/vzdump_guard.yml
T
Defame1297 f766666476
Build / build (pull_request) Successful in 31s
Lint / lint (pull_request) Successful in 2m36s
Molecule / molecule (pull_request) Successful in 7m39s
test(system_baseline): run the vzdump guard cases against the guard alone
Each of the seven vzdump cases ran the whole update entry point in check
mode, when they assert only the guard's decision. The guard now lives in
an internal tasks/vzdump_guard.yml, imported by update.yml so the update
tag, when and main-flow vars still reach it. Six cases include it
alone; the ubuntu_lxc case keeps running tasks_from: update end to end,
and a static check asserts the guard is imported before the upgrade and
that the upgrade's when reads its fact.

The purge of unwanted packages becomes one apt call over the installed
ones, skipped when none is installed. The scenario's gathering plays
use gather_subset min: the role reads only os_family and package_facts.

Closes #456

Assisted-by: Claude Code
2026-11-28 21:47:17 +00:00

53 lines
2.3 KiB
YAML

---
# Opt-in guard (system_baseline_skip_upgrade_during_vzdump, pve only): an upgrade can restart Proxmox services while a backup holds a snapshot
# of a guest, so the upgrade waits for the next run when this node has a vzdump task without an end time. Both tasks read state only, so
# they run in check mode too; they are skipped where the upgrade is (a dry run of the main flow). `localhost` is the node's own alias, so no
# node name and no gathered facts are needed. --source active lists the running tasks: the default, archive, holds only finished ones. The
# fact is set on every run, so a guard that is off or skipped never inherits the answer of an earlier run in the same play.
- name: List the recent Proxmox tasks of this node
ansible.builtin.command:
argv:
- pvesh
- get
- /nodes/localhost/tasks
- --source
- active
- --limit
- "0"
- --output-format
- json
register: __system_baseline_pve_tasks
changed_when: false
check_mode: false
become: true
when:
- system_baseline_skip_upgrade_during_vzdump | bool
- system_baseline_system_type | default('') == 'pve'
- not (ansible_check_mode and __system_baseline_main_flow | default(false))
- name: Check that pvesh answered with a list of tasks
ansible.builtin.assert:
that:
- __system_baseline_pve_tasks.stdout | from_json is sequence
- __system_baseline_pve_tasks.stdout | from_json is not string
- __system_baseline_pve_tasks.stdout | from_json is not mapping
fail_msg: pvesh did not answer with a JSON list of tasks, so the role cannot tell whether a backup is running.
quiet: true
when: __system_baseline_pve_tasks is not skipped
- name: Note whether a vzdump backup is running on this node
ansible.builtin.set_fact:
__system_baseline_vzdump_running: >-
{{ __system_baseline_pve_tasks is not skipped
and (__system_baseline_pve_tasks.stdout | from_json
| selectattr('type', 'equalto', 'vzdump')
| rejectattr('endtime', 'defined')
| list | length) > 0 }}
- name: Skip the upgrade while a vzdump backup is running
ansible.builtin.debug:
msg: >-
Skipping the apt upgrade on {{ inventory_hostname }}: a vzdump task is running on this node. Run the update again after the backup
has finished.
when: __system_baseline_vzdump_running | default(false)