role arg spec - allow file extensions in tasks_from - #75467
Conversation
Lookup the spec using the basename of the file specified in tasks_from. Since tasks_form accepts both with and without extensions, so should the argument spec lookup.
tasks_from
This allows for relative paths, absolute paths, and files with or withou an extension.
Change variable name to better reflect its contents.
|
I created a |
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
|
I do question whether we should have a list of candidates to try. We might just say this isn't supported, but here it is. Consider the following tree: What about calculating the relative path based on That way if someone provided Just a thought, based on the current solution being naive about paths. Although this PR is an improvement from one view, it actually takes away the potential features. Again, maybe this is just something we document as not being possible. |
|
@sivel, iirc, |
|
It works fine with subdirs, I tested it before I posted my last comment. |
In general, I do like this idea. The current behavior can be a bit surprising since it's pretty flexible/naive with its path searching. One concern I have is how we would then match the role arg spec to the correct entry point if the stem is the same but the relative path is different. It seems like that would complicate the arg spec names and matching quite a bit. Naming the spec |
I was thinking literally |
| return data | ||
|
|
||
|
|
||
| def stem(path): |
There was a problem hiding this comment.
per discussion, you might want to look at is_subpath (ansible.utils.path) and also put this in common/file.py or create a common/path.py?
|
I have been looking into this more and found that subdirs for The more I think about it, I do like the flexibility of having specs match the |
https://github.com/ansible/ansible/blob/devel/lib/ansible/playbook/role_include.py#L154 Remove |
SUMMARY
Lookup the spec using the basename of the last part of the path or file specified in
tasks_from. Sincetasks_formaccepts a file or path both with and without an extension, the argument spec lookup should as well.Fixes #75456
ISSUE TYPE
COMPONENT NAME
lib/ansible/playbook/role/__init__.pyTo do: