In Ansible roles, allow loads of "foo/main.yml" to fallback to "foo.yml" #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr: In Ansible roles, why do I have to make extra directory hierarchy when there's typically only one file that goes in the directory? Allow
meta.yml
as shorthand formeta/main.yml
,defaults.yml
fordefaults/main.yml
, etc.Let's say we're loading
foo/main
from a Role, but the directoryfoo
does notexist. With this very small PR, loading
foo
orfoo/main
falls back to:./foo.yml
./foo.yaml
./foo.json
A plain file
./foo
is not attempted.(Should the existence of both a
meta/
directory and ameta.yml
get a warning? Maybe, but existing code seems unconcerned — there's no warning for having bothmeta/main.yml
andmeta/main.yaml
.)Existing correct playbooks retain their meaning; every playbook in Galaxy remains valid.
Motivation
Almost all of my roles have additional levels of directory hierarchy for no gain. What's worse, all files end up being named
main.yml
; some editors have poor ergonomics when editing multiple files of the same name.