From 62ffae77645598fff305a8f5e79eedf7478478a9 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 25 Nov 2026 21:28:25 +0000 Subject: [PATCH 1/4] test(images): check become in the image-smoke scenarios Both smoke scenarios now run a become task, as every role scenario does, so a molecule image where become fails no longer passes its own pin pull request. The 26.04 scenario also carries temporary diagnostics for #376. Assisted-by: Claude Code --- .../molecule/image-smoke-2604/verify.yml | 44 +++++++++++++++++++ extensions/molecule/image-smoke/verify.yml | 11 +++++ 2 files changed, 55 insertions(+) diff --git a/extensions/molecule/image-smoke-2604/verify.yml b/extensions/molecule/image-smoke-2604/verify.yml index d38bf9a..e900416 100644 --- a/extensions/molecule/image-smoke-2604/verify.yml +++ b/extensions/molecule/image-smoke-2604/verify.yml @@ -56,3 +56,47 @@ - name: NET_ADMIN is granted, so the firewall tools can work ansible.builtin.command: iptables -S changed_when: false + + # TEMPORARY diagnostics for #376; removed before review. + - name: "DIAG #376: enable sudo debug logging" + ansible.builtin.copy: + dest: /etc/sudo.conf + content: "Debug sudo /var/log/sudo_debug.log all@debug\n" + mode: "0644" + + - name: "DIAG #376: collect account and sudo state without become" + ansible.builtin.shell: | + set +e + echo "== id: $(id)"; echo "== loginuid: $(cat /proc/self/loginuid)" + echo "== getent passwd root: $(getent passwd root)" + echo "== getent shadow root (fields): $(getent shadow root | awk -F: '{print $1":"(($2 ~ /^[!*]/)?$2:"")":"$3":"$4":"$5":"$6":"$7":"$8}')" + echo "== files shadow root (fields): $(awk -F: '$1=="root"{print $1":"(($2 ~ /^[!*]/)?$2:"")":"$3":"$4":"$5":"$6":"$7":"$8}' /etc/shadow)" + echo "== ls shadow:"; ls -l --time-style=full-iso /etc/shadow /etc/passwd + echo "== nsswitch:"; grep -E '^(passwd|group|shadow)' /etc/nsswitch.conf + echo "== date: $(date -u) days: $(( $(date +%s) / 86400 ))" + echo "== systemd: $(systemctl --version | head -1); state: $(systemctl is-system-running)" + echo "== sudo -n -u root true:"; sudo -n -u root true; echo "rc=$?" + echo "== sudo -H -S -n -u root sh -c echo:"; sudo -H -S -n -u root /bin/sh -c 'echo BECOME-SUCCESS' Date: Wed, 25 Nov 2026 21:32:18 +0000 Subject: [PATCH 2/4] test(images): try pam_rootok for become on 26.04 (temporary diagnostics) Assisted-by: Claude Code --- .../molecule/image-smoke-2604/verify.yml | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/extensions/molecule/image-smoke-2604/verify.yml b/extensions/molecule/image-smoke-2604/verify.yml index e900416..51db9bf 100644 --- a/extensions/molecule/image-smoke-2604/verify.yml +++ b/extensions/molecule/image-smoke-2604/verify.yml @@ -58,28 +58,16 @@ changed_when: false # TEMPORARY diagnostics for #376; removed before review. - - name: "DIAG #376: enable sudo debug logging" - ansible.builtin.copy: - dest: /etc/sudo.conf - content: "Debug sudo /var/log/sudo_debug.log all@debug\n" - mode: "0644" - - - name: "DIAG #376: collect account and sudo state without become" + - name: "DIAG #376: test the cause and the candidate fix without become" ansible.builtin.shell: | - set +e - echo "== id: $(id)"; echo "== loginuid: $(cat /proc/self/loginuid)" - echo "== getent passwd root: $(getent passwd root)" - echo "== getent shadow root (fields): $(getent shadow root | awk -F: '{print $1":"(($2 ~ /^[!*]/)?$2:"")":"$3":"$4":"$5":"$6":"$7":"$8}')" - echo "== files shadow root (fields): $(awk -F: '$1=="root"{print $1":"(($2 ~ /^[!*]/)?$2:"")":"$3":"$4":"$5":"$6":"$7":"$8}' /etc/shadow)" - echo "== ls shadow:"; ls -l --time-style=full-iso /etc/shadow /etc/passwd - echo "== nsswitch:"; grep -E '^(passwd|group|shadow)' /etc/nsswitch.conf - echo "== date: $(date -u) days: $(( $(date +%s) / 86400 ))" - echo "== systemd: $(systemctl --version | head -1); state: $(systemctl is-system-running)" - echo "== sudo -n -u root true:"; sudo -n -u root true; echo "rc=$?" - echo "== sudo -H -S -n -u root sh -c echo:"; sudo -H -S -n -u root /bin/sh -c 'echo BECOME-SUCCESS' Date: Wed, 25 Nov 2026 21:42:58 +0000 Subject: [PATCH 3/4] fix(images): let become work on molecule-ubuntu2604 and add gnupg In the booted 26.04 container, pam_unix's account check for sudo runs the unix_chkpwd helper, which fails there, so become from root fails with "account validation failure". /etc/pam.d/sudo now lets root through with pam_rootok before common-account; a non-root caller still goes through pam_unix. The build fails if the line does not apply. gnupg joins the image, as in the 24.04 image: the docker and gitea scenarios need it on the target. The temporary diagnostics are removed. Closes #376 Assisted-by: Claude Code --- docs/images/molecule-ubuntu2604.md | 4 +++- .../molecule/image-smoke-2604/verify.yml | 22 +------------------ images/molecule-ubuntu2604/Dockerfile | 15 +++++++++---- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/docs/images/molecule-ubuntu2604.md b/docs/images/molecule-ubuntu2604.md index f6e449c..b7d8044 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; the roles are tested on it next to 24 `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-2604/verify.yml b/extensions/molecule/image-smoke-2604/verify.yml index 51db9bf..a45cb09 100644 --- a/extensions/molecule/image-smoke-2604/verify.yml +++ b/extensions/molecule/image-smoke-2604/verify.yml @@ -33,6 +33,7 @@ - ufw - fail2ban - openssh-server + - gnupg - name: Query the units a role scenario relies on ansible.builtin.systemd: @@ -57,27 +58,6 @@ ansible.builtin.command: iptables -S changed_when: false - # TEMPORARY diagnostics for #376; removed before review. - - name: "DIAG #376: test the cause and the candidate fix without become" - ansible.builtin.shell: | - set -o pipefail - echo "== status: $(grep -E '^(Seccomp|Seccomp_filters|NoNewPrivs|CapEff)' /proc/self/status | tr '\t\n' ' ')" - echo "== unix_chkpwd root chkexpiry:"; /usr/sbin/unix_chkpwd root chkexpiry Date: Wed, 25 Nov 2026 21:47:15 +0000 Subject: [PATCH 4/4] test(images): check become on 26.04 after the fixed image is pinned The 26.04 smoke checks run against the pinned image, which gains the fix only after this change is built and pinned; they follow with the pin. Assisted-by: Claude Code --- extensions/molecule/image-smoke-2604/verify.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/extensions/molecule/image-smoke-2604/verify.yml b/extensions/molecule/image-smoke-2604/verify.yml index a45cb09..d38bf9a 100644 --- a/extensions/molecule/image-smoke-2604/verify.yml +++ b/extensions/molecule/image-smoke-2604/verify.yml @@ -33,7 +33,6 @@ - ufw - fail2ban - openssh-server - - gnupg - name: Query the units a role scenario relies on ansible.builtin.systemd: @@ -57,14 +56,3 @@ - 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 -- 2.43.0