Hey @bern . Welcome to the Forum.
I’m trying to reproduce your issue, and I’m stuck coming up with a /etc/ansible/facts.d/getUsers.fact
that works with your expression {{ ansible_facts.ansible_local.getUsers.user }}
. I’m curious what your getUsers.fact
looks like. Here’s mine:
#!/bin/bash
# /etc/ansible/facts.d/getUsers.fact
# Returns JSON of local users with id>999 and without a 'nologin' shell.
pending=''
echo -n '['
getent passwd | while IFS=: read -r user password uid gid gecos home shell; do
if [ "$uid" -gt 999 ] && [[ ! "$shell" =~ nologin ]] ; then
printf "%s{" "$pending"
printf '"user": "%s", ' "$user"
printf '"uid": "%s", ' "$uid"
printf '"home": "%s", ' "$home"
printf '"shell": "%s"}' "$shell"
pending=$',\n'
fi
done
echo ']'
Having typed all that up and reading over it, it dawned on me that maybe your ansible_facts.ansible_local.getUsers.user
expression isn’t working for you either.
Is that the problem?