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