restore role param precedence (#82106)

* add test for setfact/param override
pull/82145/head
Brian Coca 7 months ago committed by GitHub
parent 5ac62473b0
commit 20a54eb236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- role params now have higher precedence than host facts again, matching documentation, this had unintentionally changed in 2.15.

@ -406,7 +406,7 @@ class VariableManager:
# vars (which will look at parent blocks/task includes)
if task:
if task._role:
all_vars = _combine_and_track(all_vars, task._role.get_vars(task.get_dep_chain(), include_params=True, only_exports=False),
all_vars = _combine_and_track(all_vars, task._role.get_vars(task.get_dep_chain(), include_params=False, only_exports=False),
"role '%s' all vars" % task._role.name)
all_vars = _combine_and_track(all_vars, task.get_vars(), "task vars")
@ -423,6 +423,8 @@ class VariableManager:
# special case for include tasks, where the include params
# may be specified in the vars field for the task, which should
# have higher precedence than the vars/np facts above
if task._role:
all_vars = _combine_and_track(all_vars, task._role.get_role_params(task.get_dep_chain()), "role params")
all_vars = _combine_and_track(all_vars, task.get_include_params(), "include params")
# extra vars

@ -9,6 +9,10 @@
from_inventory_once_removed: "{{ inven_var | default('BAD!') }}"
vars_files:
- vars/test_var_precedence.yml
pre_tasks:
- name: param vars should also override set_fact
set_fact:
param_var: "BAD!"
roles:
- { role: test_var_precedence, param_var: "param_var" }
tasks:

Loading…
Cancel
Save