From 75f9d273291a2151bbc68e800afdb5d80d37f2d3 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 29 Nov 2026 20:00:08 +0000 Subject: [PATCH] ci(images): add git to the molecule-controller image The Molecule select job runs the selector in this image, and the selector diffs the checkout with git. Closes #488 Assisted-by: Claude Code --- docs/images/molecule-controller.md | 4 ++-- images/molecule-controller/Dockerfile | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/images/molecule-controller.md b/docs/images/molecule-controller.md index 372e3f2..fe9509f 100644 --- a/docs/images/molecule-controller.md +++ b/docs/images/molecule-controller.md @@ -17,11 +17,11 @@ Ubuntu 26.04 with: - **The collections the scenarios call** in `/opt/collections` (`ANSIBLE_COLLECTIONS_PATH` is set to it): those of `requirements.yml` (`community.general`, `ansible.posix`, `community.proxmox`), which the roles call, and of `extensions/molecule/requirements.yml` (`community.docker`), which the Docker driver's own playbooks call. -- `python3`, `python3-venv` and `ca-certificates` from the distribution. The image runs as root and sets no +- `python3`, `python3-venv`, `ca-certificates` and `git` from the distribution. The image runs as root and sets no working directory. - `/opt/molecule-pins.sha256`: the checksums of the four pin files this image was built from. -It has no Docker CLI and no `git`: mount the host's Docker CLI and socket, and the checkout. +It has no Docker CLI: mount the host's Docker CLI and socket, and the checkout. ## How to use it diff --git a/images/molecule-controller/Dockerfile b/images/molecule-controller/Dockerfile index 5f50c49..4263897 100644 --- a/images/molecule-controller/Dockerfile +++ b/images/molecule-controller/Dockerfile @@ -29,9 +29,10 @@ FROM ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da0 ENV DEBIAN_FRONTEND=noninteractive # python3 and python3-venv only bootstrap uv in the build stage; ca-certificates serve the -# install a job runs when a pull request changes a pin. apt lists are removed in the same layer. +# install a job runs when a pull request changes a pin; git lets the selector diff the checkout. +# apt lists are removed in the same layer. RUN apt-get update \ - && apt-get install -y --no-install-recommends ca-certificates python3 python3-venv \ + && apt-get install -y --no-install-recommends ca-certificates git python3 python3-venv \ && rm -rf /var/lib/apt/lists/* @@ -92,7 +93,7 @@ LABEL org.opencontainers.image.title="molecule-controller" \ org.opencontainers.image.authors="Defame1297 and contributors" \ org.opencontainers.image.base.name="ubuntu:26.04" \ net.rkdr.mortis.purpose="Molecule controller image for the mortis.kamino Ansible Collection: the Molecule workflow runs molecule in it, so a tool only Lint uses does not change it." \ - net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, molecule, molecule-plugins[docker]), /opt/collections (community.general, ansible.posix, community.proxmox, community.docker), python (the one of /opt/venv), python3 (distribution), /opt/molecule-pins.sha256" \ + net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, molecule, molecule-plugins[docker]), /opt/collections (community.general, ansible.posix, community.proxmox, community.docker), python (the one of /opt/venv), python3 and git (distribution), /opt/molecule-pins.sha256" \ net.rkdr.mortis.usage="Molecule (host executor, kamino-molecule runner): docker run as the runner user, with the Docker socket, the host Docker CLI and the checkout mounted at the same path. Run sha256sum -c /opt/molecule-pins.sha256 in the checkout root and install the pinned tools and collections when a pull request changed them, else use /opt/venv/bin and ANSIBLE_COLLECTIONS_PATH=/opt/collections. See the documentation label." ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ @@ -122,6 +123,7 @@ RUN set -eu; \ molecule --version | grep -F "molecule ${mol}"; \ molecule drivers | grep -qw docker; \ python -c "import docker"; \ + git --version; \ collections="$(ansible-galaxy collection list --format json)"; \ for c in $(sed -n 's/^ *- name: *//p' requirements.yml extensions/molecule/requirements.yml); do \ printf '%s' "$collections" | python -c "import json, sys; d = json.load(sys.stdin); sys.exit(0 if any('$c' in v for v in d.values()) else 1)" \