fix: read getent results through ansible_facts in two verify plays
Build / build (pull_request) Successful in 30s
Lint / lint (pull_request) Successful in 2m52s
Molecule / molecule (pull_request) Successful in 44m53s

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
This commit is contained in:
Dragonish committed 2026-11-26 23:58:23 +00:00
1 parent 11fec7c8fc
commit 3a5040aae8
2 files changed
+6 -6

No files matched your search

+2 -2
View File
@@ -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.
@@ -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