Compare commits

Author SHA1 Message Date
Defame1297 2b2e2c4021 ci(molecule): wrap the duration list comment
Build / build (pull_request) Successful in 1m3s
Lint / lint (pull_request) In progress
Molecule / molecule (pull_request) In progress
Part of #432

Assisted-by: Claude Code
2026-11-28 23:29:10 +00:00
Defame1297 dbcbf3b02d ci(molecule): give the measured lane times as the reason for the default
Part of #432

Assisted-by: Claude Code
2026-11-28 23:26:10 +00:00
Defame1297 40d5c49e33 ci(molecule): run two scenarios at a time by default
A full run on main took 34 minutes with 2 lanes and 35 with 4: with 4 every scenario ran
about twice as slowly, so the runner is full at two, and two leave it room for pull request
jobs. The duration list now holds the 2-lane run's times and adds nfs_client.

Closes #432

Assisted-by: Claude Code
2026-11-28 23:23:45 +00:00
10 changed files with 93 additions and 119 deletions

No files matched your search

+1 -1
View File
@@ -110,7 +110,7 @@ issue.
concurrency group of its own.** Runs may overlap on the runner's Docker daemon: every container
is named and labelled by its run (`KAMINO_RUN_ID`). The job first removes labelled containers
older than its timeout, which a cancelled run left, and finally its own. The scenarios of one
run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time, 4 unless a manual
run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time, 2 unless a manual
dispatch sets its `lanes` input), so no two scenarios may share a platform name. They start
longest first by the script's list of last full-run times, an unlisted one first; the logs stay
in selection order. *Why:* a cancelled run is killed before it can remove its instances, a
@@ -1,4 +0,0 @@
---
trivial:
- >-
system_baseline - Purge the unwanted packages that are installed in one apt call instead of one call per package.
+2 -2
View File
@@ -134,8 +134,8 @@ The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_
- Verify checks the installed and removed packages, the journal size cap, the apt settings in `20auto-upgrades` and `50unattended-upgrades`, the locale, and that systemd loaded the `apt-daily.service` timeout.
- Verify checks the tmux snippet: root-owned, valid shell, the session and quoted window command, no effect without a terminal, a session name or window command ending in a newline refused, and the file removed when autostart is off.
- Verify refuses bad items in `system_baseline_extra_packages` and `system_baseline_extra_remove_packages` (whitespace, a null, an empty string, a trailing minus, upper case, a bare string) and a package that one input installs and another purges; converge applies the `ubuntu_lxc` profile with `jq` as an extra package and `ed` as an extra removal; verify checks that `jq` is installed, `ed` is gone and the profile's packages are still there, and that an extra `tmux` installs the snippet where a flat list without it installs none.
- Verify also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. It reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, that the connection is reset afterwards, and that the vzdump guard is imported before the upgrade, whose `when` reads the guard's fact: the scenario skips the `update` tag, so the upgrade itself never runs there.
- Verify runs the vzdump guard in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`); six run the guard's task file alone and the `ubuntu_lxc` case runs the whole `update` entry point. Each case asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
- Verify also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. It reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
- Verify runs the `update` entry point in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`), and asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
- Verify ends by running the role once with `system_baseline_journal_max_use: ""` after removing the drop-in, and asserts that no drop-in is written and that `systemd-journald` was not restarted.
- Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot.
- The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list.
@@ -2,7 +2,6 @@
- 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 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.
# 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.
- name: Write the pvesh stub
check_mode: false
ansible.builtin.copy:
@@ -14,9 +14,8 @@
{{ system_baseline_case.answer | to_json }}
JSON
- name: Create the apt scratch directory, which a check mode run of the update entry point does not
- name: Create the apt scratch directory, which a check mode run 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
@@ -27,13 +26,13 @@
path: /var/tmp/pvesh-calls
state: absent
- name: Run the case's tasks in check mode
- name: Run the update entry point in check mode
check_mode: true
block:
- name: Include system_baseline, tasks_from {{ system_baseline_case.tasks_from | default('vzdump_guard') }}
- name: Include system_baseline, tasks_from update
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: "{{ system_baseline_case.tasks_from | default('vzdump_guard') }}"
tasks_from: update
vars:
system_baseline_system_type: "{{ system_baseline_case.type }}"
system_baseline_skip_upgrade_during_vzdump: "{{ system_baseline_case.input }}"
@@ -464,19 +464,6 @@
- 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.
@@ -484,7 +471,6 @@
- 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:
@@ -799,8 +785,7 @@
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. The cases run the guard
# alone; the last one runs the update entry point, so it still runs end to end in check mode.
# a system type other than pve, pvesh is never run. Only the decision is asserted: the upgrade itself is not run in CI.
- name: The vzdump guard skips the upgrade only for a running backup on a pve node
hosts: all
gather_facts: false
@@ -816,7 +801,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}], tasks_from: update}
- {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
# 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
@@ -825,7 +810,6 @@
- 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:
+3 -5
View File
@@ -12,13 +12,11 @@
manager: auto
become: true
# One apt call for every unwanted package that is installed, skipped when none is.
- name: Remove unnecessary packages if installed
ansible.builtin.package:
name: "{{ __system_baseline_purge_present }}"
name: "{{ item }}"
state: absent
purge: true
vars:
__system_baseline_purge_present: "{{ __system_baseline_purge_packages | select('in', ansible_facts.packages) | list }}"
when: __system_baseline_purge_present | length > 0
loop: "{{ __system_baseline_purge_packages }}"
when: item in ansible_facts.packages
become: true
+51 -3
View File
@@ -21,9 +21,57 @@
mode: "0700"
become: true
# import_tasks, not include_tasks: the update tag, the caller's when and __system_baseline_main_flow must reach the guard's tasks.
- name: Decide whether a vzdump backup holds back the upgrade
ansible.builtin.import_tasks: vzdump_guard.yml
# 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)
# safe is the apt module's name for the plain upgrade (apt-get upgrade --with-new-pkgs), what `true` meant here before; dist runs
# apt-get dist-upgrade (profile key apt_upgrade, `pve` by default).
@@ -1,52 +0,0 @@
---
# 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)
+27 -25
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# The Molecule workflow's "Run the scenarios" step: `molecule test` for each scenario directory on
# stdin, MOLECULE_LANES (default 4, also when empty) at a time, longest first, each with its own
# stdin, MOLECULE_LANES (default 2, also when empty) at a time, longest first, each with its own
# log and ANSIBLE_HOME under <work-dir>/<n>/ (no collection is installed there:
# .config/molecule/config.yml sets prerun false).
# Exit 1 on a failure.
@@ -8,7 +8,8 @@
# scripts/run_molecule_scenarios.sh <work-dir> < scenario-dirs
set -euo pipefail
lanes="${MOLECULE_LANES:-4}"
# 2: a full run took 34 min at 2 lanes and 35 at 4, so more lanes only slow each scenario.
lanes="${MOLECULE_LANES:-2}"
if ! [[ "$lanes" =~ ^[1-9][0-9]*$ ]]; then
echo "MOLECULE_LANES must be a positive integer, not '$lanes'" >&2
exit 2
@@ -78,30 +79,31 @@ while IFS= read -r dir; do
done
mkdir -p "$work"
# Seconds each scenario took in the last full run, so the longest start first and none started
# late sets the end of the run. Keyed by scenario directory, not label: refresh from a full run's
# `finished <label>: exit 0 after S s` lines, each label mapped back to its directory. A scenario
# missing here is assumed long and starts first.
# Seconds each scenario took in the last full run at the default lane count, so the longest start
# first and none started late sets the end of the run. Keyed by scenario directory, not label:
# refresh from a full run's `finished <label>: exit 0 after S s` lines, each label mapped back to
# its directory. A scenario missing here is assumed long and starts first.
declare -A last_seconds=(
[roles/system_baseline/molecule/default]=1127
[roles/ufw/molecule/default]=907
[roles/traefik/molecule/default]=886
[roles/gitea_runner/molecule/default]=762
[roles/cloudflared/molecule/default]=673
[roles/docker/molecule/default]=612
[roles/tailscale/molecule/default]=509
[roles/fail2ban/molecule/default]=337
[roles/systemd_hardening/molecule/default]=335
[roles/gitea/molecule/default]=301
[roles/user_management/molecule/default]=270
[roles/_binary_update/molecule/default]=248
[roles/pihole/molecule/default]=228
[roles/sshd/molecule/default]=163
[roles/pve_lxc/molecule/default]=157
[roles/network_interfaces/molecule/default]=129
[roles/_binary_update/molecule/check_mode]=81
[extensions/molecule/image-smoke]=47
[extensions/molecule/image-smoke-2604]=46
[roles/system_baseline/molecule/default]=568
[roles/ufw/molecule/default]=525
[roles/traefik/molecule/default]=484
[roles/gitea_runner/molecule/default]=398
[roles/docker/molecule/default]=352
[roles/cloudflared/molecule/default]=305
[roles/tailscale/molecule/default]=220
[roles/fail2ban/molecule/default]=161
[roles/gitea/molecule/default]=137
[roles/systemd_hardening/molecule/default]=134
[roles/_binary_update/molecule/default]=132
[roles/nfs_client/molecule/default]=126
[roles/user_management/molecule/default]=115
[roles/pihole/molecule/default]=112
[roles/sshd/molecule/default]=65
[roles/pve_lxc/molecule/default]=44
[roles/_binary_update/molecule/check_mode]=42
[roles/network_interfaces/molecule/default]=36
[extensions/molecule/image-smoke]=25
[extensions/molecule/image-smoke-2604]=21
)
# The indices of dirs in start order; ties keep the selection order (a stable sort).
mapfile -t start_order < <(