Inheritance confusion, docs needed?
As a developer creating Zuul jobs, one of the areas i find confusing is the inheritance of variables. I am not sure if this is an enhancement style request or just a missing section in the documentation. When you use host-vars, the top level variables are "merged" with the parent job variables, however the nested variables, such as "devstack_localrc" are not merged, they are "replaced". As an example is the opendev Zuul jobs (I think this applies to non-OpenStack jobs as well): When you use host-vars, the top level variables are "merged" with the parent job variables, however the nested variables, such as "devstack_localrc" are not merged, they are "replaced". host-vars: controller: devstack_localrc: DATABASE_USER: a-user In this example snippet, the variables at the devstack_localrc level are "merged", but the variables at the "DATABASE_USER" level are replaced and not inherited from the parent. Should Zuul be recursively "merging" all the way down or should we document how/which variables are inherited from the parent and which are not? The reason I'm asking is as our job definitions get more complicated (multi-node), I find myself copying variables from the parent jobs that I would really like to just inherit. Michael
Michael Johnson <johnsomor@gmail.com> writes:
The reason you see this behavior is that these are two different features of Ansible. The "vars" job attribute sets global variables for Ansible, but "host-vars" sets host-specific variables. In Ansible, host-vars override global variables. It looks like we should update the documentation to make that clear (extra-vars mentions this obliquely, but not host-vars). If you use only "vars" or "host-vars" for a given top-level variable, Zuul will merge the various values all the way down. -Jim
participants (2)
-
corvus@inaugust.com
-
Michael Johnson