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.
On Fri, Jun 25, 2021 at 1:44 PM [email protected] <[email protected]>
wrote:
> 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?
>
> ---
> - hosts: localhost
> become: yes
> become_method: sudo
> gather_facts: no
>
> vars_files:
> - /etc/ansible/vault.yml
>
> vars:
> - users:
> - { name: "user1 }
> - { name: "user2" }
>
> tasks:
>
> - name: Get User's Email Address
> shell: "set -o pipefail && /bin/ipa user-show {{ item.name }} --all
> --raw | grep mail: | awk '{print $2}'"
> register: email
> loop:
> - "{{ users }}"
>
> - name: Print email
> debug:
> msg: "{{ email.stdout }}"
>
> The error states "The task includes an option with an undefined
> variable. The error was: 'list object' has no attribute 'name'".
>
> Thanks,
> Harry
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/ac83150f-a884-4a72-8024-330f5ce8b0fen%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/ac83150f-a884-4a72-8024-330f5ce8b0fen%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Matt Martz
@sivel
sivel.net
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAD8N0v_FJiLgY3-zJnBkcfnTUFCPfxcwgJGmbiZqikFivFRA9A%40mail.gmail.com.