On Thu, Aug 27, 2015 at 10:59 AM, Eric Feliksik <
feli...@gmail.com> wrote:
> 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" ? )
hostvars is more than that, it has all vars available to the host at
the play execution time.
> 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
that seems like a bug.
> 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. "
fact caching is not applied to inventory, that does not mean inventory
won't be available.
--
Brian Coca