group variables not changing

I use group variables encountered the following problems, can you help me? Thank you.

% cat group_vars/bj

It would be helpful if you could explain the problem in words some, in terms of what you saw vs what you expected to see.

There are no known issues with group variables so it’s just a matter of explaining behavior, but that would help. Thanks!

Ah, I’ve had this issue before too. From what I can tell, the same host (localhost) appears in two different groups, bj and sh. The same variable ‘gv’ is defined in both groups. One might expect that when targeting one particular group, that vars for the explicitly targeted group will “win” in the case of a conflict. Hence in this case, the ‘gv’ var will show ‘sh’ when targeting the ‘sh’ group, and ‘bj’ when targeting the ‘bj’ group. However what happens is that shows ‘bj’ in both cases.

In my case, I did a lot of re-organizing to start using roles, etc and in the process the problem went away. Perhaps someone else can provide a “you’re thinking about this wrong, try this instead” best practices recommendation!

The last group loaded ‘wins’, there is nothing in ansible that checks the targeted group.

Ah, that.

What are the real world names and purposes of these groups? I can likely help with suggestions.

– Michael

I use a different host, now the problem has been resolved. Thanks.