I see this behavior too (in 2.4.1).  On searching, one tends to find a lot 
of "Ansible used to resolve group_vars and host_vars from the current 
directory; now it doesn't; don't do that".  But that isn't my problem, or 
yours I wager.

My suspicion is that it seems to be a problem with playbook-adjacent 
(group|host)_vars files that only is seen when specifying a inventory 
directory (additionally, possibly, specifying inventory files in a 
subdirectory). Single inventory files often tend to be in the same 
directory as playbooks, so it muddies the water sometimes when testing 
this.  It almost seems like ever since support was added for 
(group|host)_vars files adjacent to inventory, the playbook-adjacent setup 
is not tested as much (despite the best practices page and other 
documentation).



On Wednesday, November 15, 2017 at 4:29:25 PM UTC-8, Braňo Žarnovičan wrote:
>
> Hi,
>
> upgrade-ing to Ansible 2.4, I have noticed that variables defined in 
> 'group_vars/all.yaml', 'group_vars/groupX.yaml' no longer appear in 
> 'hostvars'. I'm talking about referencing hostvars of _another_ host from 
> currently executing one.
>
> I have the following directory structure:
> .
> ├── env
> │   ├── dev
> │   │   ├── group_vars
> │   │   │   └── all.yaml
> │   │   └── inventory
> │   └── prod
> │       ├── group_vars
> │       │   └── all.yaml
> │       └── inventory
> ├── group_vars
> │   └── all.yaml
> └── site.yaml
>
> Only the variables defined at "inventory" level group_vars propagate to 
> hostvars. This behavior has changed between 2.3-2.4.
>
> In Ansible 2.3, if I needed a variable in hostvars to be define for all 
> environments, I would put it to 'group_vars/all.yaml'. Now I have to 
> duplicate it to all inventory's group_vars, which is .. suboptimal.
>
> Q: is there any place (in Ansible2.4) where you could define "inventory 
> variable defaults", common for all environments/inventories ??
>
> Regards,
>
> BranoZ
>
>

-- 
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/4d220577-5808-4c56-93af-0115dd7139b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to