Using a variable in a loop

I’m trying to look through a loop of users to get their email addresses from an IPA server. When I run it, I get an error stating that “name” is an undefined variable. Can anyone see what I’m doing wrong?

Instead of:

loop:

  • “{{ users }}”

You want:

loop: “{{ users }}”

Otherwise, you are creating a list in YAML with the value of users as the single element.

Thanks! I feel stupid. That worked. However, now I’m getting an error in printing out the user’s email address. I’m registering a variable called email, and when I do the debug message, I get an error that says that stdout isn’t defined. if I just print out the variable ‘email’ I see stdout present. I’m just doing this so i can hopefully use the email later on.

Thanks,
Harry

See https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#registering-variables-with-a-loop