I know about a ./library path that can exist at the playbook level, but
I did not find any reference to a ./library path at role level. Is there
any reason why this is not supported? Would it be a desirable feature?
It seems to be the most sensible way to allow distribution of ansible
modules along with roles. The use case is that you write a role along
with some special modules needed for that role and want to distribute
your role with all needed pieces included.
Thanks, I have been resistant in including this because I don’t want to see galaxy start to fill up with modules that might be easy to include in core, but I agree it’s the time to start suggesting this now.
Note that library/ is for *modules*, that is, remotely executed code.
There's other "kind" of modules: the action_plugins. They are run in the
control machine (the host running ansible) and not remotely.
Action plugins also need a module file in library/ but the
implementation is done in other file
(lib/ansible/runner/action_plugins/...), and is quite different. The
module file is used to expose the action plugin. The difference between
both types is not appreciated from outside, but the internals are
completely different. Action plugins and modules are both mixed in the
"all modules" page of ansible documentation.
Action plugins are not officially/explicitly supported in roles, but
I've found them quite useful for several use cases. Here's one of my
implementations with an explanation of the limitations/difficulties
found and how I've workaround them - https://github.com/sbitmedia/ansible-monit/blob/master/README.md
I'm coming from puppet and this is how I've managed to bring to ansible
world some pieces I missed. Hope my experience, helps someone
I think there’re cases where a module with no garnish does not much sense. For example a module may need some package installed, or some minimal configuration done. Modules could add checks to verify the requirements are met, but there’s no pattern / facility to acomplish that afaik, and each module does it on its own, in case it does. It would be easier to provide companion roles or plays in ansible core, that need to be run before a module can be used. Those roles/plays should be overridable to allow for customizations. my 2 ¢