# Many tasks for a single loop?

**URL:** <https://forum.ansible.com/t/many-tasks-for-a-single-loop/1878>\
**Category:** Get Help\
**Tags:** playbook\
**Created:** [October 23, 2023, 6:21pm UTC](https://forum.ansible.com/t/many-tasks-for-a-single-loop/1878 "2023-10-23T18:21:56Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [October 24, 2023, 1:40am UTC](https://forum.ansible.com/t/many-tasks-for-a-single-loop/1878/3 "2023-10-24T01:40:09Z")

</div>

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:

```sh
#!/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?

---

_[View the full topic](https://forum.ansible.com/t/many-tasks-for-a-single-loop/1878)._
