Skip to content
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

In Ansible roles, allow loads of "foo/main.yml" to fallback to "foo.yml" #1

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from

Conversation

nopdotcom
Copy link
Owner

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 for meta/main.yml, defaults.yml for defaults/main.yml, etc.


Let's say we're loading foo/main from a Role, but the directory foo does not
exist
. With this very small PR, loading foo or foo/main falls back to:

  1. ./foo.yml
  2. ./foo.yaml
  3. ./foo.json

A plain file ./foo is not attempted.

(Should the existence of both a meta/ directory and a meta.yml get a warning? Maybe, but existing code seems unconcerned — there's no warning for having both meta/main.yml and meta/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.

Let's say we're loading "foo/main", but the directory "foo" *does not
exist*. With this change, loads of "foo" or "foo/main" fall back to:

1. ./foo.yml
2. ./foo.yaml
3. ./foo.json

Note that any plain file "foo" is not attempted.

Note that adding "tasks.yml" to a role with an existing "tasks"
directory will not have an effect. (Should the existence of both a
"foo" directory and a "foo.yml" get a warning?)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant