From 3a5040aae8c652754f73ad2c9e26dea8457aa804 Mon Sep 17 00:00:00 2001 From: Dragonish Date: Thu, 26 Nov 2026 23:58:23 +0000 Subject: [PATCH] fix: read getent results through ansible_facts in two verify plays The pihole and user_management scenarios read getent_passwd and getent_shadow as top-level variables. The getent module returns them as facts, which are injected as variables only while inject_facts_as_vars is on, so with the setting this pull request turns on in the molecule job the two verify plays failed (exit 2 in both runs of this pull request, whose per-scenario logs were not printed). They now read ansible_facts['getent_passwd'] and ansible_facts['getent_shadow']. The remaining module-returned facts in roles/ and extensions/ (package_facts, service_facts, the getent read in user_management's ssh_keys.yml) are already read through ansible_facts. Assisted-by: Claude Code:claude-sonnet-5-5 --- roles/pihole/molecule/default/verify.yml | 4 ++-- roles/user_management/molecule/default/verify.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/pihole/molecule/default/verify.yml b/roles/pihole/molecule/default/verify.yml index be5b64f..284c2bd 100644 --- a/roles/pihole/molecule/default/verify.yml +++ b/roles/pihole/molecule/default/verify.yml @@ -98,8 +98,8 @@ - name: The user is a system account without a login shell ansible.builtin.assert: that: - - getent_passwd.pihole[5] == '/usr/sbin/nologin' - - getent_passwd.pihole[1] | int < 1000 + - ansible_facts['getent_passwd'].pihole[5] == '/usr/sbin/nologin' + - ansible_facts['getent_passwd'].pihole[1] | int < 1000 quiet: true # Neither check run (before and after the converge) ran the installer or the handler. diff --git a/roles/user_management/molecule/default/verify.yml b/roles/user_management/molecule/default/verify.yml index 0b1c96b..567e27e 100644 --- a/roles/user_management/molecule/default/verify.yml +++ b/roles/user_management/molecule/default/verify.yml @@ -9,7 +9,7 @@ - name: The removed user is gone ansible.builtin.assert: - that: "'um-olduser' not in getent_passwd" + that: "'um-olduser' not in ansible_facts['getent_passwd']" quiet: true - name: Read group membership @@ -74,7 +74,7 @@ ansible.builtin.assert: that: - user_management_test_admin_key in (user_management_verify_keys.results[0].content | b64decode) - - getent_passwd['um-admin'][5] != '/usr/sbin/nologin' + - ansible_facts['getent_passwd']['um-admin'][5] != '/usr/sbin/nologin' quiet: true - name: Read root's shadow entry @@ -86,7 +86,7 @@ - name: Root's password is locked ansible.builtin.assert: that: - - getent_shadow['root'][0] == '!' + - ansible_facts['getent_shadow']['root'][0] == '!' quiet: true - name: Read root's authorized_keys @@ -98,5 +98,5 @@ ansible.builtin.assert: that: - (user_management_verify_root_keys.content | b64decode) is search('root-key$', multiline=true) - - getent_passwd['root'][5] == '/bin/bash' + - ansible_facts['getent_passwd']['root'][5] == '/bin/bash' quiet: true