-
Notifications
You must be signed in to change notification settings - Fork 23.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ansible 2.4 group_vars not parsed lexicographically #31689
Comments
It seems the group_vars/host_vars files are found in the function
So one can't rely on any ordering. This behaviour should at least be documented. I think it would be better to load the files in sorted order. This can be benificial for multi-stage environments to specify defaults for all environments as shown in the article How to Manage Multistage Environments with Ansible (The method shown is not reliable in the current version). Playbook group_vars can't be used beacuse they would override the inventory group_vars. |
this was never sorted, previous versions always used |
@bcoca, so your'e saying a random behaviour is better than a predicted one, simply because you got used to it? |
@Saloshp its not random, it is just not determined by our code, there is a big difference there. The code in 2.4 mostly 'moved' but was not changed when it came to finding files, you can check 2.3 as it also uses I'm not saying i'm rejecting the feature, I'm saying we need to add a toggle for those depending on the previous behaviour. |
Actually, they were sorted, and 2.4 broke this behavior. Here is the snippet from 2.3.1.0 which previously sorted the list of files: ansible/lib/ansible/vars/__init__.py Lines 559 to 566 in c7052b4
This is a valid bug and the fix in the PR is valid imo. This regression is preventing a smooth upgrade to 2.4 in one of my projects currently. |
hmm, seems we used to do 1/2 the vars one way, the other 1/2 the other ... sorted does seem more predictable so I'll add it w/o requiring a toggle. |
ISSUE TYPE
Bug ReportCOMPONENT NAME
group_vars
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
SUMMARY
group variable files of higher lexicographical order do not override lower ones
STEPS TO REPRODUCE
EXPECTED RESULTS
ok: [127.0.0.1] => {
"myvar": "02"
}
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: