HUB
Sign inSign up
molecule-ubuntu logo

jfxs/molecule-ubuntu

By jfxs

•Updated 3 days ago

A Ubuntu Docker image with systemd, to be used as a platform of Ansible Molecule (docker driver).

Image
0

778

jfxs/molecule-ubuntu repository overview

⁠Docker molecule-ubuntu

Inspired by geerlingguy/docker-ubuntu2404-ansible⁠ by Jeff Geerling (MIT License). This image is an update for the latest Ubuntu releases.

Software License Pipeline Status

An Ubuntu Docker image with systemd, to be used as a platform of Molecule⁠ (docker driver) tests of Ansible roles that manage services.

  • systemd as PID 1, with systemd-sysv, sudo, procps, iproute2 and dbus,
  • ca-certificates: the TLS trust store of any real host, so HTTPS downloads (get_url, uri) work out of the box,
  • cron, enabled at boot, for roles that manage crontabs (cron module, /etc/cron.d),
  • python3 and python3-apt: what Ansible needs on a target (the apt module). No Ansible in the image: Molecule runs on the controller and drives the container,
  • one tag per Ubuntu codename, so several versions can be tested in parallel and a project can pin one,
  • multiarch with support of amd64 and arm64,
  • automatically rebuilt every week and kept up to date by Renovate⁠ (base image digests),
  • image signed with Cosign⁠, with a software bill of materials (SBOM) attestation,
  • available on Docker Hub and Quay.io.

GitLab The main repository.

Docker Hub The Docker Hub registry.

Quay.io The Quay.io registry.

⁠Tags

TagMeaning
noble, resoluteThe last build of this Ubuntu codename (Ubuntu 24.04 and 26.04 LTS). Recommended: pin one in molecule.yml.
<codename>-NNNAn immutable build of a codename (resolute-001, resolute-002...), to reproduce a given run.
latestThe latest Ubuntu LTS (the codename of ubuntu:latest). It moves automatically to the new codename when Ubuntu releases a new LTS, once that codename is built.

Prefer the codename tag over latest in your molecule.yml: latest changes the Ubuntu version under your tests when Ubuntu publishes a new LTS.

⁠Usage with Molecule

platforms:
  - name: instance
    image: jfxs/molecule-ubuntu:resolute
    pre_build_image: true
    command: /usr/lib/systemd/systemd
    cgroupns_mode: host
    privileged: true
    tmpfs:
      - /run
      - /tmp
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:rw

Without Molecule:

docker run --detach --privileged --cgroupns=host --tmpfs /run --tmpfs /tmp \
  --volume /sys/fs/cgroup:/sys/fs/cgroup:rw jfxs/molecule-ubuntu:resolute

This image is for isolated tests, not for production.

⁠Build and test locally

task install-templates                 # fetch the task templates (first time)
task 00:10-build-local C=noble      # build molecule-ubuntu:noble (default codename: resolute)
task 00:20-test-local IMG=molecule-ubuntu:noble

Without task: docker build --build-arg VERSION=noble -t molecule-ubuntu:noble . then tests/acceptance.sh molecule-ubuntu:noble.

tests/acceptance.sh starts the container and checks that systemd is running, that python3 imports apt, that ca-certificates is installed and an HTTPS download works, that cron is installed and active at boot, and that a service (cron) can be stopped and started.

⁠Adding a Ubuntu version

Add a base stage (FROM ubuntu:<codename>@sha256:... AS base-<codename>) to the Dockerfile, an inclusion of the docker component and a matrix entry in .gitlab-ci.yml. tests/check_ci.sh verifies that the codenames agree everywhere (task 00:30-test-scripts, also run by the scripts:test CI job).

⁠Built with

Last published tags: resolute-003, resolute⁠.

Dockerhub Overview page⁠ has the details of the last published image.

⁠Signature and attestation

The image is signed with Cosign⁠ and carries a SBOM attestation:

cosign verify --key cosign.pub $IMAGE_URI
cosign verify-attestation --key cosign.pub --type spdxjson $IMAGE_URI | jq '.payload | @base64d | fromjson | .predicate'

⁠Authors

⁠License

This program is free software: you can redistribute it and/or modify it under the terms of the MIT License (MIT). See the LICENSE⁠ for details.

Tag summary
Recent tags
Content type
Image
Digest
sha256:598c94c1f…
Size
66.8 MB
Last updated
3 days ago
docker pull jfxs/molecule-ubuntu:latest