Compare commits

..
Author SHA1 Message Date
Defame1297 380d52cd13 ci: turn on Ansible pipelining for Molecule scenarios
Molecule / molecule (pull_request) Canceled after 0s
Build / build (pull_request) Canceled after 7s
Lint / lint (pull_request) Canceled after 7s
Set connection.pipelining in the shared Molecule base config. Without
it, every remote task over the community.docker.docker connection pays
extra docker exec and docker cp calls to create a temp dir, copy the
module in and clean up; with it, the module goes over stdin.

The docker connection declares has_pipelining and has no pipelining
option of its own, so core's global setting applies. No role or image
sets requiretty.

Closes #423

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 15:44:34 +00:00
Defame1297 7d11d23294 ci: share a Molecule base config with prerun off and smart gathering
Build / build (pull_request) Successful in 50s
Lint / lint (pull_request) Successful in 5m11s
Molecule / molecule (pull_request) Canceled after 16m59s
Add .config/molecule/config.yml, which molecule merges under every
scenario's molecule.yml. prerun is off: the CI wrapper already puts the
checkout first on ANSIBLE_COLLECTIONS_PATH, so molecule's per-scenario
reinstall of mortis.kamino into ANSIBLE_HOME is redundant. gathering is
smart, so each host's facts are gathered once per playbook run instead
of in every play.

Add .config to build_ignore so scripts/check_tarball.py does not fail
the build, and reword the Molecule rule and the two script comments that
said molecule installs the collection into each scenario's ANSIBLE_HOME.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 15:20:18 +00:00
14 changed files with 39 additions and 123 deletions

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
---
# Merged under every scenario's molecule.yml. prerun off: the CI wrapper puts this checkout
# first on ANSIBLE_COLLECTIONS_PATH, so molecule's per-scenario install is unused.
prerun: false
provisioner:
config_options:
connection:
# Pipe each module over stdin: without it every task pays extra docker exec and docker cp
# calls to make a temp dir, copy the module in and clean up.
pipelining: true
defaults:
# Gather each host's facts once per playbook run, not in every play.
gathering: smart
+4 -3
View File
@@ -85,9 +85,10 @@ issue.
- **A role named in an include, import, play `roles:` entry or meta dependency is written out in
full**, never bare or templated. *Why:* the selector finds dependent roles by their FQCN.
*Held:* control: a selector test fails a bare or templated name.
- **Scenarios load `mortis.kamino` from the checkout, never from molecule's installed copy, so
`galaxy.yml` is on IGNORED.** *Why:* molecule installs the collection from `galaxy.yml` into
each scenario's `ANSIBLE_HOME`, which is not on `ANSIBLE_COLLECTIONS_PATH`, so its changes
- **Scenarios load `mortis.kamino` from the checkout, never from an installed copy, so
`galaxy.yml` is on IGNORED.** *Why:* the checkout is first on `ANSIBLE_COLLECTIONS_PATH` and the
shared base config `.config/molecule/config.yml` turns off molecule's install of the collection
(`prerun: false`), so changes to `galaxy.yml`
(release versions, `build_ignore`) do not change what a scenario runs, and the Build check
proves the collection builds; they had caused about a third of full pull request runs and their
minutes (#338). *Held:* control: `scripts/check_scenarios_load_checkout.py`, which
@@ -1,5 +0,0 @@
---
minor_changes:
- >-
traefik - New input ``traefik_release_url`` sets where the release archive and checksums are
downloaded from, for a mirror (default: the GitHub releases, as before).
+1
View File
@@ -39,6 +39,7 @@ build_ignore:
- apm_modules
- .apm-local
- .claude
- .config
- .gitea
- .gitignore
- .pre-commit-config.yaml
+2 -3
View File
@@ -30,7 +30,6 @@ The role targets Ubuntu hosts that run the reverse proxy, not Proxmox nodes, so
| `traefik_version` | pinned in `defaults/main.yml` | no | Release tag to install. |
| `traefik_arch` | `amd64` | no | Archive architecture. |
| `traefik_os` | `linux` | no | Archive OS. |
| `traefik_release_url` | github.com release directory of `traefik_version` | no | Directory URL of the archive and its checksums file, no trailing slash (templated). |
| `traefik_archive_name` | `traefik_<version>_<os>_<arch>.tar.gz` | no | Archive file name (templated). |
| `traefik_local_archive` | `/tmp/traefik.tar.gz` | no | Download destination, removed after extraction. |
| `traefik_bin_path` | `/usr/local/bin/traefik` | no | Binary path used by the unit and version checks; only the `traefik` file of the archive is extracted into its directory, so the file name must stay `traefik`. Only the `traefik` file is extracted, so the archive's `CHANGELOG.md` and `LICENSE.md` never land there. |
@@ -80,14 +79,14 @@ Update or remove: pass `-e traefik_update=true`, or `-e "traefik_remove=true tra
## Tests
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It needs outbound network: the role installs packages with apt and the converge downloads the real Traefik release from GitHub. Converge runs `mortis.kamino.ufw`, then the role. It runs `check` before the converge (on a fresh host) and after it (on the configured host). Verify covers:
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It needs outbound network: the role installs packages with apt and downloads real Traefik releases from GitHub. Converge runs `mortis.kamino.ufw`, then the role. It runs `check` before the converge (on a fresh host) and after it (on the configured host). Verify covers:
- The input guards, first: one play expects the failure message containing `unauthenticated Traefik dashboard` (the dashboard guard: enabled without valid `user:hash` users); the next expects `collides with the middleware`, raised by the dashboard-auth collision assert, which runs whenever users are set, also with the dashboard off.
- The install: the pinned version runs, and only the binary is left from the archive.
- Files: `traefik.env` mode 0600 owned by root, `dynamic.yml` mode 0600 owned by `traefik`, `traefik.yml` mode 0600, the binary mode 0755; the logrotate configuration, which `logrotate --debug` parses.
- Rendering: the ACME resolvers render when set and are absent when empty; the dashboard is off by default with the extra app routed, and renders behind basicAuth when enabled (a template render, not a running dashboard).
- The service: running and enabled with `NoNewPrivileges`, `MemoryDenyWriteExecute` and `CAP_NET_BIND_SERVICE`, listening on 80 and 443 and redirecting http to https; ufw allows 80 and 443 next to SSH, with the traefik owner tag, in order.
- The update path: it updates to another release and back with `traefik_update` (download from local `file://` stand-in releases, checksum check and swap) and asserts the version, an active unit and no leftovers. It leaves the stand-in stub installed, so nothing after it asserts real Traefik behaviour.
- The update path: it updates to another release and back with `traefik_update` (a real download, checksum check and swap) and asserts the version, an active unit and no leftovers.
- The remove path, last: unit and binary are deleted, the service is no longer active, and only the traefik ufw rules are removed.
The scenario disables the namespace-based sandboxing and the `User=` switch with a drop-in because its container is unprivileged, so that sandboxing is not covered by CI. Certificate issuance is not covered: the Cloudflare credentials are dummies.
-2
View File
@@ -9,8 +9,6 @@ traefik_version: "v3.7.19"
traefik_arch: "amd64"
traefik_os: "linux"
# Directory URL holding the release archive and its checksums file.
traefik_release_url: "https://github.com/traefik/traefik/releases/download/{{ traefik_version }}"
traefik_archive_name: "traefik_{{ traefik_version }}_{{ traefik_os }}_{{ traefik_arch }}.tar.gz"
traefik_local_archive: "/tmp/traefik.tar.gz"
-8
View File
@@ -63,14 +63,6 @@ argument_specs:
default: linux
description:
- Operating system part of the release archive name.
traefik_release_url:
type: raw
description:
- >-
URL of the directory holding the release archive and C(traefik_<traefik_version>_checksums.txt),
without a trailing slash. The role default is the Jinja expression
C(https://github.com/traefik/traefik/releases/download/<traefik_version>); point it at a mirror
for a host without access to github.com.
traefik_archive_name:
type: raw
description:
+2 -6
View File
@@ -2,9 +2,8 @@
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
# .gitea/workflows/molecule.yml. Needs outbound network, unlike most scenarios: the role installs
# packages with apt and the converge downloads the Traefik release from GitHub (verify's update
# path uses file:// stand-ins built by prepare.yml). No privileged mode: systemd needs a writable
# cgroup and the firewall tools need NET_ADMIN.
# packages with apt and downloads Traefik releases from GitHub. No privileged mode: systemd needs a
# writable cgroup and the firewall tools need NET_ADMIN.
driver:
name: docker
platforms:
@@ -55,9 +54,6 @@ provisioner:
traefik_cloudflare_email: [email protected]
traefik_cloudflare_api_token: molecule-not-a-token
traefik_domain: example.test
# Any release other than the role default: verify's update path goes there and back,
# from the stand-ins prepare.yml builds.
traefik_verify_other_version: v3.7.18
ufw_rules:
- {rule: allow, port: 22, proto: tcp, comment: ssh}
# TEST-NET-1 address: nothing answers, the value only has to render
@@ -40,55 +40,3 @@
ProtectKernelTunables=no
ReadWritePaths=
User=
# Stand-in releases for verify's update path, behind file:// URLs: the role's download, checksum
# check and swap run unchanged, without fetching two more real releases per host. The converge
# still downloads the real role default from GitHub.
- name: Prepare the stand-in releases
hosts: all
gather_facts: false
vars_files:
- ../../defaults/main.yml
tasks:
- name: Create a directory per stand-in release
ansible.builtin.file:
path: "/opt/molecule-download/{{ traefik_test_release }}"
state: directory
mode: "0755"
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
loop_control:
loop_var: traefik_test_release
# Answers `version` like Traefik and otherwise stays up like the service.
- name: Write the stand-in binaries
ansible.builtin.copy:
dest: "/opt/molecule-download/{{ traefik_test_release }}/traefik"
mode: "0755"
content: |
#!/bin/sh
case "$1" in
version) echo "Version: {{ traefik_test_release | regex_replace('^v', '') }}" ;;
*) exec sleep infinity ;;
esac
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
loop_control:
loop_var: traefik_test_release
- name: Pack the stand-in archives
ansible.builtin.command:
argv: [tar, -czf, "{{ traefik_test_archive }}", -C, "/opt/molecule-download/{{ traefik_test_release }}", traefik]
creates: "{{ traefik_test_archive }}"
vars:
traefik_test_archive: "/opt/molecule-download/{{ traefik_test_release }}/traefik_{{ traefik_test_release }}_{{ traefik_os }}_{{ traefik_arch }}.tar.gz"
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
loop_control:
loop_var: traefik_test_release
- name: Write the checksums files in the release format
ansible.builtin.shell:
cmd: sha256sum traefik_*.tar.gz > traefik_{{ traefik_test_release }}_checksums.txt
chdir: "/opt/molecule-download/{{ traefik_test_release }}"
creates: "traefik_{{ traefik_test_release }}_checksums.txt"
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
loop_control:
loop_var: traefik_test_release
@@ -5,7 +5,6 @@
vars:
traefik_update: true
traefik_version: "{{ traefik_verify_target }}"
traefik_release_url: "file:///opt/molecule-download/{{ traefik_verify_target }}"
- name: Read the Traefik version after the update to {{ traefik_verify_target }}
ansible.builtin.command: /usr/local/bin/traefik version
+11 -38
View File
@@ -107,40 +107,13 @@
name: traefik
register: traefik_unit
# The dummy credentials make the ACME request fail, logged as "Unable to obtain ACME certificate
# for domain(s)". The log keeps the lines of the process converge restarted, so only a line
# stamped (RFC 3339, first field) since the running process started counts.
- name: Wait until the running Traefik has logged the ACME failure
ansible.builtin.shell:
executable: /bin/bash
cmd: |
set -euo pipefail
started=$(systemctl show --timestamp=unix -P ExecMainStartTimestamp traefik)
if [[ ! $started =~ ^@[0-9]+$ ]]; then
echo "no start time for traefik: '${started}'" >&2
exit 1
fi
last=$(grep 'Unable to obtain ACME certificate' /etc/traefik/logs/traefik.log | tail -n 1 | cut -d ' ' -f 1) || true
# Fails closed: a missing line, an unparseable stamp or an older one all end in exit 1.
if [ -n "$last" ] && stamp=$(date -d "$last" +%s) && [ "$stamp" -ge "${started#@}" ]; then
exit 0
fi
echo "no ACME failure logged since Traefik started at ${started} (last: ${last:-none})" >&2
exit 1
register: traefik_acme_failure
changed_when: false
until: traefik_acme_failure.rc == 0
retries: 30
delay: 2
- name: Let the ACME failures against the dummy credentials play out
ansible.builtin.pause:
seconds: 15
- name: Read the service state after the ACME failure
- name: Read the service state after the wait
ansible.builtin.service_facts:
- name: Read the restart count after the ACME failure
ansible.builtin.systemd:
name: traefik
register: traefik_unit_after_acme
- name: The pinned version is installed
ansible.builtin.assert:
that:
@@ -251,8 +224,6 @@
that:
- ansible_facts.services['traefik.service'].state == 'running'
- ansible_facts.services['traefik.service'].status == 'enabled'
# Restart=always would hide a crash on the ACME failure from the state above.
- traefik_unit_after_acme.status.NRestarts == '0'
- traefik_unit.status.NoNewPrivileges == 'yes'
- traefik_unit.status.MemoryDenyWriteExecute == 'yes'
- "'cap_net_bind_service' in traefik_unit.status.AmbientCapabilities | lower"
@@ -293,15 +264,17 @@
traefik_ufw_key_443: "{{ ('allow|443|||||in' | hash('sha1'))[:10] }}"
traefik_ufw_tagged: "{{ traefik_ufw_added.stdout_lines | select('match', '^ufw ') | select('search', 'ansible-ufw') | list }}"
# A version bump through the update path and mortis.kamino._binary_update: down to another
# release and back to the role default, both with traefik_update, from prepare.yml's stand-ins.
# After the idempotence step, because each run changes the binary, and before the remove path.
# It leaves the stand-in stub installed, so nothing after it may assert real Traefik behaviour.
- name: Verify the update path with stand-in releases
# A real version bump through the update path and mortis.kamino._binary_update: down to another
# release and back to the role default, both with traefik_update. After the idempotence step,
# because each run changes the binary, and before the remove path, which deletes it.
- name: Verify the update path with real Traefik releases
hosts: all
gather_facts: false
vars_files:
- ../../defaults/main.yml
vars:
# Any published release other than the role default, with a checksum file.
traefik_verify_other_version: v3.7.18
tasks:
- name: The other release differs from the role default
ansible.builtin.assert:
+2 -2
View File
@@ -12,7 +12,7 @@
# would otherwise be kept and then fail the checksum check.
- name: Download Traefik archive
ansible.builtin.get_url:
url: "{{ traefik_release_url }}/{{ traefik_archive_name }}"
url: "https://github.com/traefik/traefik/releases/download/{{ traefik_version }}/{{ traefik_archive_name }}"
dest: "{{ traefik_local_archive }}"
mode: "0644"
force: true
@@ -20,7 +20,7 @@
- name: Download Traefik checksums
ansible.builtin.get_url:
url: "{{ traefik_release_url }}/traefik_{{ traefik_version }}_checksums.txt"
url: "https://github.com/traefik/traefik/releases/download/{{ traefik_version }}/traefik_{{ traefik_version }}_checksums.txt"
dest: /tmp/traefik_checksums.txt
mode: "0644"
force: true
+2 -2
View File
@@ -29,8 +29,8 @@ else
fi
ansible --version
molecule --version
# The collection under test first; molecule also installs it into each scenario's ANSIBLE_HOME,
# which the run script keeps in the job tree.
# The collection under test first; molecule does not install it again (prerun is off in
# .config/molecule/config.yml).
export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections"
# Facts are not injected as variables (deprecated in ansible-core 2.22, removal scheduled for 2.24, see #364), so a
# role that reads a bare `ansible_<fact>` fails its scenario here instead of in a consumer's inventory.
+2 -1
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
# The Molecule workflow's "Run the scenarios" step: `molecule test` for each scenario directory on
# stdin, MOLECULE_LANES (default 4) at a time, each with its own log and ANSIBLE_HOME under
# <work-dir>/<n>/ (molecule reinstalls the collection there with --force). Exit 1 on a failure.
# <work-dir>/<n>/ (no collection is installed there: .config/molecule/config.yml sets prerun false).
# Exit 1 on a failure.
#
# scripts/run_molecule_scenarios.sh <work-dir> < scenario-dirs
set -euo pipefail