Commit 0c40c6c2 by James Cammarata

Fix order of resolving dependent role variables from vars files

Also adds a new class to the test_var_precedence test to check for
this type of error in the future.

Fixes #9178
parent 402d0c37
......@@ -287,7 +287,8 @@ class Play(object):
if os.path.isfile(vars):
vars_data = utils.parse_yaml_from_file(vars, vault_password=self.vault_password)
if vars_data:
dep_vars = utils.combine_vars(vars_data, dep_vars)
#dep_vars = utils.combine_vars(vars_data, dep_vars)
dep_vars = utils.combine_vars(dep_vars, vars_data)
defaults = self._resolve_main(utils.path_dwim(self.basedir, os.path.join(dep_path, 'defaults')))
dep_defaults_data = {}
if os.path.isfile(defaults):
......
---
# should be overridden by vars_files in the main play
vars_files_var: "BAD!"
# should be seen in role1 (no override)
defaults_file_var_role1: "defaults_file_var_role1"
- debug: var=extra_var
- debug: var=param_var
- debug: var=vars_var
- debug: var=vars_files_var
- debug: var=vars_files_var_role
- debug: var=defaults_file_var_role1
- assert:
that:
- 'extra_var == "extra_var"'
- 'param_var == "param_var_role1"'
- 'vars_var == "vars_var"'
- 'vars_files_var == "vars_files_var"'
- 'vars_files_var_role == "vars_files_var_dep"'
- 'defaults_file_var_role1 == "defaults_file_var_role1"'
---
# should override the global vars_files_var since it's local to the role
# but will be set to the value in the last role included which defines it
vars_files_var_role: "vars_files_var_dep"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment