Ok thanks for clearing this up.
Just to be sure: it is not possible to access variables for hosts that are
not in the inventory?



On Fri, 16 Sep 2022 at 16:25, Brian Coca <[email protected]> wrote:

> > vars_files:
> >    - group_vars/web/main.yml
> Do not load group_vars/host_vars directly, this is the job of the vars
> plugin,
> you create duplicate entries and mask the actual expected values from
> normal precedence resolution.
>
>  >  msg: '{{ hostvars[groups[''web''][0]].foopass }}: ''dict object''
> has no attribute ''web'''
> This is not because host is not in current play, it is because the
> host is not in inventory, which is a very different issue.
>
> If you want to skip the tasks conditionally, check that the group is
> present and has at least one host:
>
>    when: "'web' in groups and groups['web'][0]"
>
>
> ----------
> Brian Coca
>
> --
> 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/CACVha7dH1f2YH76XvHaUs5%3D00GD%2B6XcZoFMeb-C%3DOxE%2BGd%2BaxA%40mail.gmail.com
> .
>
-- 
Sent from Gmail Mobile

-- 
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/CAF8BbLYBKJuBhZq70t56DQX3j9Q9TkwSbzVfSwk2Je15uN3-Tg%40mail.gmail.com.

Reply via email to