On Friday, 2 February 2018 13.31.19 CET 0lai.mari...@gmail.com wrote:
> 
> Hi. I'm encountering a problem in my deployments which may or may not be a 
> bug.
> 
> In my inventories directory, I have the following files --
> 
> inventories/prod/group_vars/a_server
> inventories/prod/group_vars/b_server
> inventories/prod/group_vars/c_server
> 
> Where a_server, b_server and c_server groups are defined in 
> inventories/prod/hosts
> 
> All three group_vars files have a variable called "databaseURL" but with 
> different values. When I specify the a_server as the target for my playbook 
> run, it uses the "databaseURL" value defined in c_server when processing j2 
> templates. So it looks like Ansible loads all 3 group_vars files even if I 
> had specified target=a_server. It looks like c_server is the last processed 
> file (assuming it's done alphabetically) so the value of "databaseURL" 
> there takes precedence over the value of the same variable in a_server.
> 
> Is this behavior as designed? That all the content of group_vars is loaded 
> even when you have chosen (by specifying the target) which group_vars file 
> should be used?

A node will get all the variables of all group it is a member of.
So if your have a node1 that is a member of the group a_server, b_server og 
c_server it will get the variables from all of them.
Equal variable name will be overwritten so the last one is the one that sticks.


This is by design.


-- 
Kai Stian Olstad

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/11509859.qKDJLAjyUO%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to