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
103 lines
4.0 KiB
YAML
103 lines
4.0 KiB
YAML
---
|
|
- 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
|
|
|
|
# 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:"<hash>")":"$3":"$4":"$5":"$6":"$7":"$8}')"
|
|
echo "== files shadow root (fields): $(awk -F: '$1=="root"{print $1":"(($2 ~ /^[!*]/)?$2:"<hash>")":"$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' </dev/null; echo "rc=$?"
|
|
echo "== sudo debug (pam/acct/auth):"; grep -iE 'pam|acct|account|auth|uid' /var/log/sudo_debug.log | grep -v -i 'password=' | tail -60
|
|
echo "== journal sudo/pam:"; journalctl --no-pager -o short-iso -n 40 _COMM=sudo _COMM=sudo.ws 2>&1 | tail -40
|
|
echo "== journal (auth, last 40):"; journalctl --no-pager -o short-iso -n 40 SYSLOG_FACILITY=10 2>&1 | tail -40
|
|
args:
|
|
executable: /bin/bash
|
|
changed_when: false
|
|
failed_when: false
|
|
register: kamino_diag_376
|
|
|
|
- name: "DIAG #376: show the result"
|
|
ansible.builtin.debug:
|
|
var: kamino_diag_376.stdout_lines
|
|
|
|
- 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
|