Ok, I poked around a bit and indeed found one precedence issue and one
premature templating issue:
In lib/ansible/runner/__init__.py lines 612-613:
module_vars_inject = utils.combine_vars(host_variables,
combined_cache.get(host, {}))
module_vars_inject = utils.combine_vars(self.module_vars,
module_vars_inject)
module_vars are overrided by host_variables, although they are supposed to
be of high precedence. They are being used in the correct order
(module_vars > host_variables) when building the inject var. Changing the
order of precedence in the above lines solves my first use-case (the
mapping override one).
In lib/ansible/playbook/play.py lines 89-90:
all_vars = utils.combine_vars(self.vars, self.playbook.extra_vars)
self.vars = template(basedir, self.vars, all_vars)
play vars are templated without taking inventory variables into account.
Removing these lines solves my second use-case (defining a variable in vars
section based on inventory var with a default value).
make tests seem to pass. Is there a chance that someone with more knowledge
of how vars behave can verify if my fixes are correct? Should I open a PR
for this?
Thanks
--
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/591094e7-c26d-4fe0-a9c2-e8c34a9f8160%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.