Filtering variables

I am using getent to search for user details; however, I only wish for information regarding 3 users. I can’t seem to find a way to get a filter to work.

`

  • debug:
    var: getent_passwd.(‘user1’|‘user2’|‘user3’)

`

I am doing something wrong, but could use a nudge in the right direction. I know if I specify getent_passwd.user1, I see the info just for that user… I am just trying to expand it to 3 users.

- debug: var=getent_passwd[item]
  with_items:
    - user1
    - user2
    - user3

Perfect, thx Kai. One follow-up question. Why getent_passwd[item] instead of getentpasswd.[item] (notice the dot)?

getent_passwd.user1 is the same as getent_passwd['user1'] it's just different syntax.

But when you are using variables you need the , if not item is taken as the string "item" and not the variable item.