From b27513f0bdfaebff62dfc9da7b5f8e05515f0dbe Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Mon, 26 Oct 2026 19:16:51 +0000 Subject: [PATCH] feat(molecule): test the 26.04 image and move the 24.04 pin to 0.1.2 Adds the image-smoke-2604 scenario (asserts Ubuntu 26.04) and the MOLECULE_IMAGE_2604 pin (molecule-ubuntu2604 0.1.0, the digest its first build printed, run 2534). Moves MOLECULE_IMAGE to molecule-ubuntu2404 0.1.2 (digest printed by run 2541): the 0.1.1 image is Ubuntu 26.04, so image-smoke has failed on main since the base bump. The Renovate pattern for the multi-line pin now also reads MOLECULE_IMAGE_. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm --- .gitea/workflows/molecule.yml | 12 ++-- CLAUDE.md | 3 +- .../molecule/image-smoke-2604/converge.yml | 7 +++ .../molecule/image-smoke-2604/molecule.yml | 27 +++++++++ .../molecule/image-smoke-2604/verify.yml | 58 +++++++++++++++++++ renovate.json | 4 +- 6 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 extensions/molecule/image-smoke-2604/converge.yml create mode 100644 extensions/molecule/image-smoke-2604/molecule.yml create mode 100644 extensions/molecule/image-smoke-2604/verify.yml diff --git a/.gitea/workflows/molecule.yml b/.gitea/workflows/molecule.yml index 396b11e..bec2877 100644 --- a/.gitea/workflows/molecule.yml +++ b/.gitea/workflows/molecule.yml @@ -1,8 +1,8 @@ name: Molecule # Behavioural tests of the Collection: every molecule scenario under -# extensions/molecule/*/ and roles/*/molecule/*/. extensions/molecule/image-smoke -# tests the test image itself, so it runs even before any role exists. +# extensions/molecule/*/ and roles/*/molecule/*/. extensions/molecule/image-smoke and +# image-smoke-2604 test the test images themselves, so they run even before any role exists. # # It runs on the `kamino-molecule` label, a host executor on kamino-runner, which uses # that LXC's own Docker daemon; no job container is given the Docker socket. That makes @@ -16,7 +16,7 @@ name: Molecule # Tooling is provisioned on the runner by the gitea_runner role (molecule venv and the # collections the roles use); this job installs nothing. 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 version. +# image.yml publishes a new molecule-ubuntu2404 or molecule-ubuntu2604 version. on: # yamllint disable-line rule:truthy pull_request: branches: @@ -64,7 +64,11 @@ jobs: # Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run # one locally. MOLECULE_IMAGE: >- - git.rkdr.net/mortis/molecule-ubuntu2404:0.1.1@sha256:c8b22948fdb741de292a7af8a298600b5090cd9df163b3bb44adf01615161f94 + git.rkdr.net/mortis/molecule-ubuntu2404:0.1.2@sha256:206bff48aa0af74da388f5a030d74da86876037a18dc5572c1f141ce0cf801d3 + # The same for Ubuntu 26.04, the release the hosts are moving to; used by + # `image: ${MOLECULE_IMAGE_2604}` in extensions/molecule/image-smoke-2604. + MOLECULE_IMAGE_2604: >- + git.rkdr.net/mortis/molecule-ubuntu2604:0.1.0@sha256:b46550ae60543b722217813a1b1d1b072793019ef3fceec9c2a3cc90c3cd1bd4 steps: # Provisioned by the gitea_runner role (install_services); fail with a clear # message when this runs before it has. diff --git a/CLAUDE.md b/CLAUDE.md index 6bc6ced..419eac7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,7 +41,8 @@ protection, or create tags: those are the operator's. checksums baked into the image: a PR that changes `requirements-dev.txt` or `.pre-commit-config.yaml` takes the slower path that installs the pinned tools. - Molecule discovers `extensions/molecule/*/` and `roles/*/molecule/*/`. The `image-smoke` - scenario tests the molecule image itself. + and `image-smoke-2604` scenarios test the molecule images themselves (24.04 and 26.04); a role scenario that + must pass on both takes `image: ${MOLECULE_IMAGE}` or `${MOLECULE_IMAGE_2604}` per platform. ## Images (`images/`) diff --git a/extensions/molecule/image-smoke-2604/converge.yml b/extensions/molecule/image-smoke-2604/converge.yml new file mode 100644 index 0000000..e017fe3 --- /dev/null +++ b/extensions/molecule/image-smoke-2604/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + gather_facts: true + tasks: + - name: Reach the instance over the container connection + ansible.builtin.ping: diff --git a/extensions/molecule/image-smoke-2604/molecule.yml b/extensions/molecule/image-smoke-2604/molecule.yml new file mode 100644 index 0000000..e2d5479 --- /dev/null +++ b/extensions/molecule/image-smoke-2604/molecule.yml @@ -0,0 +1,27 @@ +--- +# Tests the molecule test image itself (images/molecule-ubuntu2604): the contract the +# role scenarios rely on. Same instance settings as a role scenario: systemd needs a +# writable cgroup, the firewall tools need NET_ADMIN, nothing is privileged. The image +# comes from the environment (MOLECULE_IMAGE_2604, set by .gitea/workflows/molecule.yml). +driver: + name: docker +platforms: + - name: image-smoke-2604 + image: ${MOLECULE_IMAGE_2604} + pre_build_image: true + pull: true + command: /sbin/init + cgroupns_mode: host + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw + tmpfs: + - /run + - /run/lock + capabilities: + - NET_ADMIN + security_opts: + - apparmor=unconfined +provisioner: + name: ansible +verifier: + name: ansible diff --git a/extensions/molecule/image-smoke-2604/verify.yml b/extensions/molecule/image-smoke-2604/verify.yml new file mode 100644 index 0000000..d38bf9a --- /dev/null +++ b/extensions/molecule/image-smoke-2604/verify.yml @@ -0,0 +1,58 @@ +--- +- name: Verify the molecule image contract + hosts: all + gather_facts: true + tasks: + - name: The instance is Ubuntu 26.04 with systemd as the service manager + ansible.builtin.assert: + that: + - ansible_facts['distribution'] == 'Ubuntu' + - ansible_facts['distribution_version'] == '26.04' + - ansible_facts['service_mgr'] == 'systemd' + quiet: true + + - name: Gather package facts + ansible.builtin.package_facts: + manager: auto + + - name: The packages the roles manage are preinstalled + ansible.builtin.assert: + that: item in ansible_facts['packages'] + quiet: true + loop: + - systemd + - systemd-sysv + - dbus + - sudo + - iproute2 + - ca-certificates + - python3 + - python3-apt + - python3-systemd + - iptables + - ufw + - fail2ban + - openssh-server + + - name: Query the units a role scenario relies on + ansible.builtin.systemd: + name: "{{ item }}" + register: kamino_smoke_units + loop: + - dbus + - ssh + + - name: The dbus unit is running and ssh is enabled + ansible.builtin.assert: + that: + - (kamino_smoke_units.results | selectattr('item', 'equalto', 'dbus') | first).status.ActiveState == 'active' + - (kamino_smoke_units.results | selectattr('item', 'equalto', 'ssh') | first).status.UnitFileState == 'enabled' + quiet: true + + - name: The Python bindings Ansible's apt and systemd support need import + ansible.builtin.command: /usr/bin/python3 -c 'import apt, systemd.journal' + changed_when: false + + - name: NET_ADMIN is granted, so the firewall tools can work + ansible.builtin.command: iptables -S + changed_when: false diff --git a/renovate.json b/renovate.json index abb1fec..946a2c9 100644 --- a/renovate.json +++ b/renovate.json @@ -69,12 +69,12 @@ }, { "customType": "regex", - "description": "The MOLECULE_IMAGE value of molecule.yml is a multi-line `>-` scalar, which the github-actions manager does not read; matched here by its exact shape. Used by the pin-follow rule below.", + "description": "The MOLECULE_IMAGE and MOLECULE_IMAGE_ values of molecule.yml are a multi-line `>-` scalar, which the github-actions manager does not read; matched here by its exact shape. Used by the pin-follow rule below.", "managerFilePatterns": [ "/^\\.gitea/workflows/molecule\\.yml$/" ], "matchStrings": [ - "MOLECULE_IMAGE:\\s*>-\\s*\\n\\s*(?git\\.rkdr\\.net/mortis/[a-z0-9._-]+):(?[^@\\s]+)@(?sha256:[0-9a-f]{64})" + "MOLECULE_IMAGE(?:_[0-9]+)?:\\s*>-\\s*\\n\\s*(?git\\.rkdr\\.net/mortis/[a-z0-9._-]+):(?[^@\\s]+)@(?sha256:[0-9a-f]{64})" ], "datasourceTemplate": "docker", "versioningTemplate": "semver"