Two Molecule runs could not overlap on one Docker daemon because every scenario's container name was fixed; only the runner's single slot kept them apart. Each platform is now named and labelled by KAMINO_RUN_ID (run id and attempt, "local" outside CI), the run script expands those names with molecule's own interpolator before removing them, and the workflow removes its own containers by label and only sweeps labelled leftovers older than the job timeout, so a run still going is never hit. Non-pull-request runs get a concurrency group of their own. Push to main no longer triggers Molecule, Lint or Build: a merged pull request was already tested, and the nightly and manual Molecule runs cover every scenario. Build keeps its v* tag trigger. Assisted-by: Claude Code:claude-opus-5-5
90 lines
4.0 KiB
YAML
90 lines
4.0 KiB
YAML
---
|
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
|
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No Cloudflare and no real
|
|
# cloudflared: prepare.yml starts a stub of the Cloudflare API on the controller's loopback
|
|
# (files/cloudflare_api_stub.py, reached through cloudflared_api_base_url; cleanup.yml stops it)
|
|
# and seeds a stub cloudflared binary that reports an older version, so the update downloads its
|
|
# new stub from local file:// URLs. The scenario downloads nothing. cloudflared_manage_dns is
|
|
# false here because community.general.cloudflare_dns cannot be pointed at the stub; the DNS
|
|
# guards in front of it are run with it true in verify.yml.
|
|
# The container runs systemd as PID 1 with a writable cgroup; no privileged mode.
|
|
driver:
|
|
name: docker
|
|
platforms:
|
|
- name: ${KAMINO_RUN_ID:-local}-cloudflared-instance
|
|
labels:
|
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
|
image: ${MOLECULE_IMAGE}
|
|
pre_build_image: true
|
|
pull: true
|
|
command: /sbin/init
|
|
cgroupns_mode: host
|
|
volumes:
|
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
|
tmpfs:
|
|
- /run
|
|
- /run/lock
|
|
security_opts:
|
|
- apparmor=unconfined
|
|
provisioner:
|
|
name: ansible
|
|
# One source for every play, so a verify play that runs the role again renders the same
|
|
# configuration.
|
|
inventory:
|
|
group_vars:
|
|
all:
|
|
# The stub binary; @VERSION@ is replaced per release file. Its hash is the configured
|
|
# sha256, so the release files need no checksum file.
|
|
cloudflared_test_stub: |
|
|
#!/bin/sh
|
|
case "$$1" in
|
|
--version) echo "cloudflared version @VERSION@ (built 2026-01-01-0000 UTC)" ;;
|
|
tunnel)
|
|
[ "$$2" = --config ] || { echo "stub cloudflared: expected --config" >&2; exit 2; }
|
|
case "$$4" in
|
|
ingress) grep -q 'service: http_status:404' "$$3" && { echo "Validating rules from $$3"; exit 0; } ;;
|
|
run) [ -r "$$3" ] && exec sleep infinity ;;
|
|
esac
|
|
echo "stub cloudflared: cannot handle: $$*" >&2; exit 1 ;;
|
|
*) echo "stub cloudflared: unexpected arguments: $$*" >&2; exit 2 ;;
|
|
esac
|
|
cloudflared_test_stub_dir: "{{ lookup('ansible.builtin.env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/cloudflare-stub"
|
|
cloudflared_test_tunnel_id: 6f1a6e2c-0000-4000-8000-000000000001
|
|
cloudflared_test_credentials_json: >-
|
|
{"AccountTag": "molecule-account", "TunnelID": "6f1a6e2c-0000-4000-8000-000000000001", "TunnelSecret": "bW9sZWN1bGU="}
|
|
cloudflared_version: "2026.2.0"
|
|
cloudflared_sha256_amd64: "{{ cloudflared_test_stub | replace('@VERSION@', cloudflared_version) | hash('sha256') }}"
|
|
cloudflared_download_url: "file:///opt/molecule-download/cloudflared-{{ cloudflared_version }}"
|
|
cloudflared_api_base_url: >-
|
|
http://127.0.0.1:{{ lookup('ansible.builtin.file', cloudflared_test_stub_dir ~ '/port') }}/client/v4
|
|
cloudflared_account_id: molecule-account
|
|
cloudflared_tunnel_api_token: molecule-not-a-token
|
|
cloudflared_tunnel_id: "{{ cloudflared_test_tunnel_id }}"
|
|
cloudflared_credentials_json: "{{ cloudflared_test_credentials_json }}"
|
|
cloudflared_manage_dns: false
|
|
cloudflared_ingress: "{{ cloudflared_test_ingress }}"
|
|
cloudflared_test_ingress:
|
|
- hostname: app.example.test
|
|
service: https://127.0.0.1:443
|
|
originRequest:
|
|
originServerName: app.example.test
|
|
- hostname: other.example.test
|
|
service: http://127.0.0.1:8080
|
|
verifier:
|
|
name: ansible
|
|
scenario:
|
|
# molecule's default sequence minus both destroys: the workflow removes the container as soon as
|
|
# this scenario ends, and a later run removes one a killed run left; molecule's destroy only adds
|
|
# the driver's poll wait. After a local run, run `molecule destroy` yourself.
|
|
test_sequence:
|
|
- dependency
|
|
- cleanup
|
|
- syntax
|
|
- create
|
|
- prepare
|
|
- converge
|
|
- idempotence
|
|
- side_effect
|
|
- verify
|
|
- cleanup
|