-
Notifications
You must be signed in to change notification settings - Fork 24k
role arg spec - allow file extensions in tasks_from
#75467
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
base: devel
Are you sure you want to change the base?
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 |
test/integration/targets/roles_arg_spec/test_path_extension.yml
Outdated
Show resolved
Hide resolved
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 |
@@ -217,3 +219,13 @@ def unquote(data): | |||
if is_quoted(data): | |||
return data[1:-1] | |||
return data | |||
|
|||
|
|||
def stem(path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_form
accepts 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__.py
To do: