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
This commit is contained in:
1 parent
716baa19c7
commit
f766666476
8 files changed
+93
-65
No files matched your search
@@ -2,6 +2,7 @@
|
||||
- name: Converge the LXC profile
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
gather_subset: [min]
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_extra_packages: [jq]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
# One case of the vzdump guard: a pvesh stub answers with system_baseline_case_answer, the update entry point runs in check mode, and the
|
||||
# fact that decides the upgrade, and whether pvesh was asked at all, are compared with what the case expects. Kept outside the role's own tasks:
|
||||
# no CI image is a Proxmox node, so the stub stands for the real `pvesh get /nodes/<node>/tasks` answer.
|
||||
# One case of the vzdump guard: a pvesh stub answers with system_baseline_case.answer, the role's tasks_from file (the guard alone unless the
|
||||
# case names update) runs in check mode, and the fact that decides the upgrade, and whether pvesh was asked at all, are compared with what the
|
||||
# case expects. Kept outside the role's own tasks: no CI image is a Proxmox node, so the stub stands for the real `pvesh get` answer.
|
||||
- name: Write the pvesh stub
|
||||
check_mode: false
|
||||
ansible.builtin.copy:
|
||||
@@ -14,8 +14,9 @@
|
||||
{{ system_baseline_case.answer | to_json }}
|
||||
JSON
|
||||
|
||||
- name: Create the apt scratch directory, which a check mode run does not
|
||||
- name: Create the apt scratch directory, which a check mode run of the update entry point does not
|
||||
check_mode: false
|
||||
when: system_baseline_case.tasks_from | default('vzdump_guard') == 'update'
|
||||
ansible.builtin.file:
|
||||
path: /var/cache/system-baseline-apt-tmp
|
||||
state: directory
|
||||
@@ -26,13 +27,13 @@
|
||||
path: /var/tmp/pvesh-calls
|
||||
state: absent
|
||||
|
||||
- name: Run the update entry point in check mode
|
||||
- name: Run the case's tasks in check mode
|
||||
check_mode: true
|
||||
block:
|
||||
- name: Include system_baseline, tasks_from update
|
||||
- name: Include system_baseline, tasks_from {{ system_baseline_case.tasks_from | default('vzdump_guard') }}
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
tasks_from: update
|
||||
tasks_from: "{{ system_baseline_case.tasks_from | default('vzdump_guard') }}"
|
||||
vars:
|
||||
system_baseline_system_type: "{{ system_baseline_case.type }}"
|
||||
system_baseline_skip_upgrade_during_vzdump: "{{ system_baseline_case.input }}"
|
||||
|
||||
@@ -464,6 +464,19 @@
|
||||
- system_baseline_verify_update_tasks is search('(?m)^ ansible.builtin.meta:\sreset_connection$')
|
||||
quiet: true
|
||||
|
||||
# The guard cases below run vzdump_guard.yml alone, so this holds the wiring: the guard is imported before the upgrade, and the upgrade
|
||||
# task's when reads the guard's fact.
|
||||
- name: The vzdump guard is imported before the upgrade, and the upgrade waits on its fact
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- >-
|
||||
system_baseline_verify_update_tasks is search('(?ms)^ ansible\.builtin\.import_tasks:\svzdump_guard\.yml$'
|
||||
~ '.*^- name:\sUpdate & upgrade apt packages$')
|
||||
- >-
|
||||
system_baseline_verify_update_tasks is search('(?m)^- name:\sUpdate & upgrade apt packages\n(?: .*\n)*?'
|
||||
~ ' - not \(__system_baseline_vzdump_running \| default\(false\)\)$')
|
||||
quiet: true
|
||||
|
||||
# The reboot entry point is a supported interface: with system_baseline_reboot_if_required
|
||||
# false it only sets system_baseline_reboot_required. Here and not in converge, because it
|
||||
# creates and removes the marker file, which the idempotence run would report as a change.
|
||||
@@ -471,6 +484,7 @@
|
||||
- name: The reboot entry point only computes the fact when told not to reboot
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
gather_subset: [min]
|
||||
tasks:
|
||||
- name: Remove the reboot marker
|
||||
ansible.builtin.file:
|
||||
@@ -785,7 +799,8 @@
|
||||
tags: always
|
||||
|
||||
# The vzdump guard (system_baseline_skip_upgrade_during_vzdump): a running backup is a vzdump task without an endtime. With the input off, or on
|
||||
# a system type other than pve, pvesh is never run. Only the decision is asserted: the upgrade itself is not run in CI.
|
||||
# a system type other than pve, pvesh is never run. Only the decision is asserted: the upgrade itself is not run in CI. The cases run the guard
|
||||
# alone; the last one runs the update entry point, so it still runs end to end in check mode.
|
||||
- name: The vzdump guard skips the upgrade only for a running backup on a pve node
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
@@ -801,7 +816,7 @@
|
||||
- {type: pve, input: true, running: false, asked: true, answer: [{type: qmstart, upid: b, starttime: 1}]}
|
||||
- {type: pve, input: true, running: false, asked: true, answer: []}
|
||||
- {type: pve, input: false, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
||||
- {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
||||
- {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}], tasks_from: update}
|
||||
|
||||
# An empty system_baseline_journal_max_use leaves journald alone: with the drop-in gone, the role neither writes it again nor restarts
|
||||
# systemd-journald. It runs last, because it applies the role with its defaults (the converge's tmux autostart and apt-daily timeout are
|
||||
@@ -810,6 +825,7 @@
|
||||
- name: An empty journal size cap leaves journald alone
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
gather_subset: [min]
|
||||
tasks:
|
||||
- name: Remove the drop-in and its directory
|
||||
ansible.builtin.file:
|
||||
|
||||
Reference in new issue
Block a user