A small rephrase as my statement above is not fully true:
hostvars are templated but restricted to variables in the hostvars for
that host itself, so hostvars that depend on variables in other scopes
are not templated. Under the hood templating fails but this is non
fatal as we expect it often,
I think I got it. Thanks Brian
On Thu, Mar 21, 2024 at 9:50 AM Brian Coca wrote:
> Both are valid approaches but do different things, hostvars will
> provide a untemplated subset of what you can get through the vars
> lookups for the case of 'inventory_hostname', but the lookups do not
>
Both are valid approaches but do different things, hostvars will
provide a untemplated subset of what you can get through the vars
lookups for the case of 'inventory_hostname', but the lookups do not
currently expose hostvars for other hosts.
--
--
Brian Coca (he/him/yo)
--
You
This question is targeted at Matt Martz and Brian Coca (but anyone should
feel free to jump in). I recently asked a question about how to access a
variable in a task. Matt, you recommended
hostvars[inventory_hostname][item], and Brian, you recommended
lookup('vars', item). I remember a