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 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
This commit is contained in:
1 parent
bdb34cf98e
commit
068bec93a9
5 files changed
+34
-8
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
+2
-1
@@ -29,7 +29,8 @@
|
||||
},
|
||||
"ansible-galaxy": {
|
||||
"managerFilePatterns": [
|
||||
"/^requirements\\.yml$/"
|
||||
"/^requirements\\.yml$/",
|
||||
"/^extensions/molecule/requirements\\.yml$/"
|
||||
]
|
||||
},
|
||||
"pre-commit": {
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
When <head-ref> starts with `renovate/`, the diff of <base-ref>...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/<name>/Dockerfile: the tag and digest of FROM lines (the image name stays), and
|
||||
the `uv==<version>` 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")
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user