One question about the default variables of dependency roles override in ansible 2.0

Hi all,

Upgrade to ansible 2.0, my playbook activities changed. I have a question about default variables of dependency roles.

I have a role A which depends on role B. Role B is defined in meta/main.yml of role A.
Actually, I want to override one default variable “var_a” of Role B. So I define “var_a” again in default/main.yml of Role A. By this way I override “var_a” with ansible 1.9. But when I use ansible 2.0, “var_a” could not be overridden again.

I am not sure whether it is a bug of ansible 2.0 or it is the enhancement of ansible 2.0.

Which is the best way to override the default variables of dependency role which is defined in meta/main.yml?

Thank you very much!

– Rella

In 2.0 we defined this behavior (it was undefined and changed in
previous versions), roles will prefer their own defaults, you can
override these by setting the var anywhere else except in the defaults
of another role.

Actually, I did test by setting the var of role B in vars folder of role A. Role A defines role B in meta. Override is failed. Role B would be executed before role A. So role A cannot override any vars of role B. If I want override vars of role B, I must set vars in playbook or inventory, right?
So I suppose “anywhere” except in the defaults of another role you said is not really exact.

tasks still execute in order, so 'anywhere prior' if you want to split hairs.

Exactly the same problem I am also facing. Could you please share that how did you resolve this issue?

If role A depends on role B and you want to override the default var of role B by role A, you can define this var in vars/main.yml of role A. I use this solution in ansible 2.0.2.0.