I noticed odd behavior with Ansible lookups a while back and, thinking it 
was a bug, reported it here 
<https://github.com/ansible/ansible/issues/37604>. Essentially, when I 
defined a lookup in host_vars, and referenced it in different ways from the 
same role, the lookup was executing with a different 'relative search 
path'. Brian told me this was by design, since my tasks different contexts. 
I'm not sure I understand the distinction though. Here is the role in 
question:

---
# Does lookup with respect to role
- name: direct reference
  debug:
    msg: "{{ users }}"
   
# Does lookup with respect to playbook
- name: reference through hostvars
  debug:
    msg: "{{ hostvars['SERVER_NAME']['users'] }}"


What's different about the context for these two tasks? How can I know a 
priori how a lookup is going to execute, without doing guess-and-check?

Thanks so much for your help!

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1099f139-7a02-49ac-8aeb-0c483ed3b8b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to