From 068bec93a917be75a07e121b9446b07c157e3e64 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sat, 14 Nov 2026 14:30:11 +0000 Subject: [PATCH] fix(molecule): install community.docker for the Docker driver Every scenario failed in its create step (couldn't resolve module community.docker.docker_login): molecule's Docker driver runs community.docker modules in its own create and destroy playbooks, and the collection came from the runner-provisioned /opt/molecule-collections that the previous commit stopped reading. The roles do not call it, so it is not in requirements.yml, which the ci image bakes for Lint and which Renovate would rebuild the image for. It is pinned in extensions/molecule/requirements.yml instead; the Molecule job installs both files, cached by their combined checksum. Renovate tracks the new file and the bot-diff gate allows only its version: lines. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG --- .gitea/workflows/molecule.yml | 13 ++++++++----- extensions/molecule/requirements.yml | 10 ++++++++++ renovate.json | 3 ++- scripts/check_bot_pr_diff.py | 6 ++++-- tests/scripts/test_check_bot_pr_diff.py | 10 ++++++++++ 5 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 extensions/molecule/requirements.yml diff --git a/.gitea/workflows/molecule.yml b/.gitea/workflows/molecule.yml index a9d3074..a33fa62 100644 --- a/.gitea/workflows/molecule.yml +++ b/.gitea/workflows/molecule.yml @@ -20,7 +20,8 @@ name: Molecule # # The molecule venv is provisioned on the runner by the gitea_runner role. The collections # the roles use are this repository's own pins (requirements.yml, the file the ci image bakes -# for Lint): the job installs them, cached on the runner by the file's checksum. The test image is pulled from +# for Lint), and the driver's own collection is pinned in extensions/molecule/requirements.yml: +# the job installs both, cached on the runner by their checksum. The test image is pulled from # the registry by tag and digest (the digest is what is enforced). Bump both here when # image.yml publishes a new molecule-ubuntu2404 or molecule-ubuntu2604 version. on: # yamllint disable-line rule:truthy @@ -109,21 +110,23 @@ jobs: git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; } echo "Checked out $(git rev-parse HEAD)" - # The collections of requirements.yml, exactly as pinned. They are installed into a temporary + # The collections of requirements.yml (what the roles call) and extensions/molecule/requirements.yml + # (what molecule's Docker driver calls), exactly as pinned. They are installed into a temporary # directory and renamed into place, so a cancelled run never leaves a half-installed set, and - # the directory is named by the file's checksum, so a changed pin installs a new set and an - # unchanged one is reused. ANSIBLE_COLLECTIONS_PATH is set to the target for the install: + # the directory is named by the checksum of both files, so a changed pin installs a new set and + # an unchanged one is reused. ANSIBLE_COLLECTIONS_PATH is set to the target for the install: # a copy found elsewhere (the runner user's ~/.ansible) would be skipped as already installed. - name: Install the pinned collections working-directory: ac/ansible_collections/mortis/kamino run: | export PATH="$MOLECULE_VENV/bin:$PATH" - sum="$(sha256sum requirements.yml | cut -c1-16)" + sum="$(cat requirements.yml extensions/molecule/requirements.yml | sha256sum | cut -c1-16)" dest="${XDG_CACHE_HOME:-$HOME/.cache}/kamino-collections/$sum" if [ ! -d "$dest/ansible_collections" ]; then mkdir -p "$(dirname "$dest")" tmp="$(mktemp -d "$dest.XXXXXX")" ANSIBLE_COLLECTIONS_PATH="$tmp" ansible-galaxy collection install -r requirements.yml -p "$tmp" + ANSIBLE_COLLECTIONS_PATH="$tmp" ansible-galaxy collection install -r extensions/molecule/requirements.yml -p "$tmp" rm -rf "$dest" mv -T "$tmp" "$dest" fi diff --git a/extensions/molecule/requirements.yml b/extensions/molecule/requirements.yml new file mode 100644 index 0000000..ba4458b --- /dev/null +++ b/extensions/molecule/requirements.yml @@ -0,0 +1,10 @@ +--- +# Collections the Molecule test harness itself calls, as opposed to the roles under test (those are +# in the requirements.yml at the repository root, which the ci image also bakes for Lint). The +# Docker driver of molecule-plugins runs community.docker modules in its own create and destroy +# playbooks, so every scenario needs it. The Molecule job (.gitea/workflows/molecule.yml) installs +# this file next to the root one; the ci image does not, because Lint never runs a driver. +# Renovate (renovate.json, ansible-galaxy manager) bumps this pin. +collections: + - name: community.docker + version: 5.4.0 diff --git a/renovate.json b/renovate.json index 5b96681..66ea30a 100644 --- a/renovate.json +++ b/renovate.json @@ -29,7 +29,8 @@ }, "ansible-galaxy": { "managerFilePatterns": [ - "/^requirements\\.yml$/" + "/^requirements\\.yml$/", + "/^extensions/molecule/requirements\\.yml$/" ] }, "pre-commit": { diff --git a/scripts/check_bot_pr_diff.py b/scripts/check_bot_pr_diff.py index eaf40ec..367716a 100644 --- a/scripts/check_bot_pr_diff.py +++ b/scripts/check_bot_pr_diff.py @@ -7,7 +7,8 @@ When starts with `renovate/`, the diff of ...HEAD may only touch: * requirements-dev.txt: pinned `name==version` lines, the same packages before and after; - * requirements.yml: `version:` lines (the collection names, and every other line, stay); + * requirements.yml and extensions/molecule/requirements.yml: `version:` lines (the collection + names, and every other line, stay); * .pre-commit-config.yaml: `rev:` lines; * images//Dockerfile: the tag and digest of FROM lines (the image name stays), and the `uv==` token of a line that holds one; @@ -60,6 +61,7 @@ UBUNTU_LINE = re.compile( rf"^(\s*job_image:\s*ubuntu)(?::{TAG})?@sha256:[0-9a-f]{{64}}\s*$" ) DOCKERFILE = re.compile(r"images/[^/]+/Dockerfile") +COLLECTION_PINS = {"requirements.yml", "extensions/molecule/requirements.yml"} CONSUMERS = { ".gitea/workflows/lint.yml", ".gitea/workflows/build.yml", @@ -132,7 +134,7 @@ def file_problem(path, removed, added): reduce_requirement, "a pinned `name==version` line of the same package", ) - if path == "requirements.yml": + if path in COLLECTION_PINS: return same_shape(removed, added, reduce_version, "a `version:` line") if path == ".pre-commit-config.yaml": return same_shape(removed, added, reduce_rev, "a `rev:` line") diff --git a/tests/scripts/test_check_bot_pr_diff.py b/tests/scripts/test_check_bot_pr_diff.py index 9d4645c..690e466 100644 --- a/tests/scripts/test_check_bot_pr_diff.py +++ b/tests/scripts/test_check_bot_pr_diff.py @@ -56,6 +56,11 @@ class RuleTest(unittest.TestCase): cases = [ ("requirements-dev.txt", "reuse==6.2.0", "reuse==6.3.0"), ("requirements.yml", " version: 14.0.0", " version: 14.1.0"), + ( + "extensions/molecule/requirements.yml", + " version: 14.0.0", + " version: 14.1.0", + ), (".pre-commit-config.yaml", " rev: v1.0.0", " rev: v1.1.0"), ( "images/ci/Dockerfile", @@ -95,6 +100,11 @@ class RuleTest(unittest.TestCase): cases = [ ("requirements-dev.txt", "reuse==6.2.0", "evil==1.0"), ("requirements.yml", " version: 14.0.0", " version: '*'"), + ( + "extensions/molecule/requirements.yml", + " version: 14.0.0", + " source: https://evil.example", + ), ( "requirements.yml", " version: 14.0.0",