Searching the role path when developing a module

Hi, i’m currently writing a module that takes a directory of configuration files as an argument. What would I need to do to have it take an argument ‘foo’, and find it at either ansible_base_dir/foo and ansible_base_dir/roles/rolename/foo

I assume you mean an action plugin? (as basic modules don’t take files as inputs)

This is the path_dwim stuff that all the other modules do, you might want to look at something like “action_plugins/copy” for reference.