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
include_vars should not error on files with non-matching extensions #35745
Comments
Files identified in the description: If these files are inaccurate, please update the |
It functions as intended and designed, this 'feature' was only thing you could not do already in loops.
I actually recommend using loop instead in almost any case, even when you need the 'foreign file alert', its better to just have a |
So, generally I get how maybe the new loop stuff provides an alternate path. However, i just went to implement new something using this, and again i'm reading through the examples. These examples just don't make sense in a scenario where non-matching files throw an error.
Just reading the names (which i get are overly descriptive for the sake of documentation) my gut just screams... what about the non-matching extensions?! Additionally, nothing in the module documentation states that this is expected behavior. Finally, using the module as defined by its help documentation and its defined parameters is significantly more discoverable than using lookups in inline jinja. oh wait.. and it doesnt help that it doesnt work in 2.4 ?
of course if i use |
Not just 'new loop', old I cannot speak to docs but to discussions when the 'feature' was being developed, I even 'fixed' this at one point as part of removing restrictions on the 'naked' |
@gregswift when I initially updated the module with the current help it did work as expected, but some of the features I added were taken out if I am not mistaken, shortly after being merged. Since I label all of my vars with yml or json all worked as expected as I didn't realize not everyone gives extensions to the vars files. I have a locally modified version that I use that is essentially the initial revision that was merged in. That being said I do not have a good answer for you, but I can send you the version I am using and that is 100% compliant with the documentation string. I currently use it with Ansible 2.4.2 |
So far in my playing
Returns only the last file parsed inside the variable 'test' (yes i'm aware of the other discussions around this). However, using include_vars by itself, like this, brings them all together just fine:
Frankly, the reason this has been an annoyance is that I like to include README's in the base of my repositories, and ansible just really seems to hate that concept (inventory throws a warning and per this ticket, include_vars errors). While I get that the docs work 100% as they read, it is also possible to read the There seems to be 3 paths afaict:
|
processing to ignore non-valid file extensions Fixes ansible#35745 Signed-off-by: Adam Miller <admiller@redhat.com>
that commit looks great. thanks @maxamillion |
processing to ignore non-valid file extensions Fixes ansible#35745 Signed-off-by: Adam Miller <admiller@redhat.com>
🎉 👯♂️ 👯♀️ 🎉 thanks for the work @maxamillion |
@gregswift anytime, happy to help! |
processing to ignore non-valid file extensions Fixes ansible#35745 Signed-off-by: Adam Miller <admiller@redhat.com>
ISSUE TYPE
COMPONENT NAME
include_vars
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
N/A
SUMMARY
When using the include_vars module if the directory or any of its nested directories contain a file that doesn't match the default or defined extension the task will fail. By default
include_vars
looks for yml, yaml, and json files. If we add the files to theignore_files
parameter explicitly then things work. Seems like this shouldn't be necessary.STEPS TO REPRODUCE
While this will happen regardless of how you manage the directory, I think my example shows a good use case for the why. In this case I'm using is checking out a git repo that has files that need to be included in. That repository has a README.md, Jenkinsfile, and Makefile along with the var files ending in a .yml extension. The playbook checks out the git repo, and then tries to load all included files.
EXPECTED RESULTS
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: