Thanks for your response Brian. 

Op maandag 24 augustus 2015 15:25:11 UTC+2 schreef Brian Coca:
>
> hostvars are accessible even if the host is not targeted, what is not 
> available are host facts (part of hostvars),



A lot of confusion now. I see the following terms of which I don't know the 
exact definition: 
- facts (is this 'live facts gathered from the machine, 
like ansible_os_distribution)
- inventory variables (is this "variables defined in the inventory file, 
and variables defined in host_vars and group_vars" ? )
- hostvars ( is this "facts + inventory variables" ? )

In that case, I mean inventory variables here. It turns out *group_vars 
are available*, but *host_vars are not*. For a variable 'fqdn' defined in 
host_vars/B, it doesn't work for me with Ansible 1.9.2. 
I use {{hostvars['B'].fqdn}} in a playbook and run with --limit A. The 
error is clear: 

fatal: [B] => {'msg': "AnsibleUndefinedVariable: One or more undefined 
variables: 'dict object' has no attribute 'fqdn'", 'failed': True}


It does work if I do --limit A,B . Remember, the fqdn variable is defined 
in the yaml file host_vars/B
 

>  in 1.8-1.9 you can use 
> fact caching to get around this issue and still work with --limit. 
>

I read https://github.com/ansible/ansible/issues/12048 as the exact 
opposite of this statement: 
"Fact caching is for 'caching facts', group and host vars are not included, 
this was never intended to cache inventory variables just facts gathered 
from hosts to avoid the expense of gathering them every time. " 

Advice is much appreciated! 

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/df4e7749-2735-4081-ab32-b28738ea1672%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to