diff --git a/.gitea/workflows/molecule.yml b/.gitea/workflows/molecule.yml index 768390a..d76791c 100644 --- a/.gitea/workflows/molecule.yml +++ b/.gitea/workflows/molecule.yml @@ -62,7 +62,7 @@ jobs: # 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.6@sha256:d7c216b33d18fa8f1ecbfee8795eb4adc867fe5ad8e7a73b7c67effe301cf771 + git.rkdr.net/mortis/molecule-ubuntu2604:0.1.7@sha256:86ee99fe77ab4c9af3911570ae7238ce525375cfaf923e9656860606c47488df # Names and labels this run's containers: the scenarios' as `${KAMINO_RUN_ID:-local}-` # with the label net.rkdr.mortis.molecule-run, and the one molecule runs in. KAMINO_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }} diff --git a/docs/images/molecule-ubuntu2604.md b/docs/images/molecule-ubuntu2604.md index 9c375c0..f53f2ff 100644 --- a/docs/images/molecule-ubuntu2604.md +++ b/docs/images/molecule-ubuntu2604.md @@ -12,7 +12,9 @@ It is the release the hosts are moving to; every role scenario whose role declar `ca-certificates`. - Python for Ansible on the target: `python3`, `python3-apt`, `python3-systemd`. - The packages the roles manage, preinstalled so a converge makes no network calls: - `iptables`, `ufw`, `fail2ban`, `openssh-server` (the `ssh` unit is enabled). + `iptables`, `ufw`, `fail2ban`, `openssh-server` (the `ssh` unit is enabled), and `gnupg` + (the docker scenario signs its stand-in APT repository with it). +- root's `sudo` skips the PAM account check (`pam_rootok`), so `become` works in the container. - Throwaway SSH host keys and a machine-id generated at build time. They are not secrets and the image is a test target that must never be exposed to a network. diff --git a/extensions/molecule/image-smoke/verify.yml b/extensions/molecule/image-smoke/verify.yml index b9d627f..0d9e767 100644 --- a/extensions/molecule/image-smoke/verify.yml +++ b/extensions/molecule/image-smoke/verify.yml @@ -57,3 +57,14 @@ - name: NET_ADMIN is granted, so the firewall tools can work ansible.builtin.command: iptables -S changed_when: false + + - name: Run a task with become, as the role scenarios do + ansible.builtin.command: id -u + become: true + changed_when: false + register: kamino_smoke_become + + - name: Become reaches root + ansible.builtin.assert: + that: kamino_smoke_become.stdout == '0' + quiet: true diff --git a/images/molecule-ubuntu2604/Dockerfile b/images/molecule-ubuntu2604/Dockerfile index d57c63d..b495f2d 100644 --- a/images/molecule-ubuntu2604/Dockerfile +++ b/images/molecule-ubuntu2604/Dockerfile @@ -17,7 +17,7 @@ # One RUN layer: about 30 MB compressed on top of the 29.8 MB base (estimated from # the real .debs, with the .pyc files the postinst scripts compile), far below # Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as -# one request). apt packages are not version-pinned, as in the original image; the +# one request; gnupg adds a few MB, not measured). apt packages are not version-pinned, as in the original image; the # base image is pinned by digest and a rebuild is a reviewed digest bump downstream. # # The image carries SSH host keys and a machine-id generated at build time (the @@ -36,7 +36,7 @@ LABEL org.opencontainers.image.title="molecule-ubuntu2604" \ org.opencontainers.image.authors="Defame1297 and contributors" \ org.opencontainers.image.base.name="ubuntu:26.04" \ net.rkdr.mortis.purpose="Disposable Ubuntu 26.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection." \ - net.rkdr.mortis.contents="Ubuntu 26.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, ufw, fail2ban, openssh-server (ssh enabled)" \ + net.rkdr.mortis.contents="Ubuntu 26.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, ufw, fail2ban, openssh-server (ssh enabled), gnupg" \ net.rkdr.mortis.usage="Molecule docker-driver platform with pre_build_image true, command /sbin/init, cgroupns_mode host, /sys/fs/cgroup mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN, security_opts apparmor=unconfined (not privileged). Pin git.rkdr.net/mortis/name:version@sha256:digest. See the documentation label." ENV DEBIAN_FRONTEND=noninteractive @@ -44,15 +44,22 @@ ENV DEBIAN_FRONTEND=noninteractive # systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on # the target (python3-apt for the apt module); the firewall and intrusion-prevention # packages the roles manage (python3-systemd is a dependency of fail2ban's systemd -# backend); sshd, enabled so a converge can test it under systemd. +# backend); sshd, enabled so a converge can test it under systemd; gnupg, which the docker +# scenario signs its stand-in APT repository with and which would otherwise cost it an +# apt update and install in every run. +# root's sudo (Ansible's become here) skips pam_unix's account check, whose unix_chkpwd +# helper fails inside the container; non-root callers still go through pam_unix. RUN apt-get update \ && apt-get install -y --no-install-recommends \ systemd systemd-sysv dbus sudo iproute2 ca-certificates \ python3 python3-apt python3-systemd \ iptables ufw fail2ban \ openssh-server \ + gnupg \ && rm -rf /var/lib/apt/lists/* \ - && systemctl enable ssh + && systemctl enable ssh \ + && sed -i '0,/^@include common-account/s//account sufficient pam_rootok.so\n@include common-account/' /etc/pam.d/sudo \ + && grep -qx 'account sufficient pam_rootok.so' /etc/pam.d/sudo STOPSIGNAL SIGRTMIN+3 CMD ["/sbin/init"] diff --git a/requirements-dev.lock b/requirements-dev.lock index a865286..cbb959b 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -214,10 +214,14 @@ ansible-lint==26.10.1 \ # via # -r requirements-dev.txt # galaxy-importer -antsibull-changelog==0.37.0 \ - --hash=sha256:649105fe6ccd4f035688c4e2e580573660712af1e46f8c0d3d8891352ffc7e2e \ - --hash=sha256:c9fb0e7625b208ae4ea6fe3633bc0dbeb029bcd2a79da36a8ef7f5a256beadc4 +antsibull-changelog==0.38.0 \ + --hash=sha256:674989862b8518ad14bb3ba2b149dc4d70f180666102e0f104864efa6f62ae21 \ + --hash=sha256:a37d7cd00943e97ed076eb9426a7cd5cd675b247209300ea719948ceaddc9d63 # via -r requirements-dev.txt +antsibull-docs-loader==1.0.0 \ + --hash=sha256:92ec1647c24e9006efe7bb7525f3087b9ac70c878da2f2a1b105e7485fd7b240 \ + --hash=sha256:c1c08623c14d3fc02add4b927678690174f8a082543ea0a48fd61e3647dcd053 + # via antsibull-changelog antsibull-docs-parser==1.2.3 \ --hash=sha256:0d4835c615b6ae1b64d219d42260c2e1b58b6312809599e8e1a63adf7797e968 \ --hash=sha256:66d593ad90d5499112cc3167fb178bfa787b496eb883102dfe12a4a4047406ba @@ -1939,6 +1943,7 @@ pyyaml==6.0.4 \ # ansible-compat # ansible-core # ansible-lint + # antsibull-docs-loader # antsibull-fileutils # apm-cli # galaxy-importer diff --git a/requirements-dev.txt b/requirements-dev.txt index 6882701..1cd271c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -9,7 +9,7 @@ ansible-core==2.22.0 ansible-lint==26.10.1 pre-commit==4.7.0 -antsibull-changelog==0.37.0 +antsibull-changelog==0.38.0 galaxy-importer==0.4.44 reuse==6.3.0 molecule==26.11.0