# Distribute special modules along with roles

**URL:** <https://forum.ansible.com/t/distribute-special-modules-along-with-roles/15098>\
**Category:** Ansible Project\
**Created:** [April 28, 2014, 9:56am UTC](https://forum.ansible.com/t/distribute-special-modules-along-with-roles/15098 "2014-04-28T09:56:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ernest0x](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@Ernest0x](https://forum.ansible.com/u/Ernest0x)\
**Post date:** [April 28, 2014, 9:56am UTC](https://forum.ansible.com/t/distribute-special-modules-along-with-roles/15098/1 "2014-04-28T09:56:48Z")

</div>

Hello,

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.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 28, 2014, 11:24am UTC](https://forum.ansible.com/t/distribute-special-modules-along-with-roles/15098/2 "2014-04-28T11:24:35Z")

</div>

It is possible actually.

When in doubt, try it and see.

However, it should not be considered something you want to do often. In general, you should work on getting the module(s) added to core ansible.

---

<div class="post-metadata">

**Author:** ![Ernest0x](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@Ernest0x](https://forum.ansible.com/u/Ernest0x)\
**Post date:** [April 28, 2014, 12:07pm UTC](https://forum.ansible.com/t/distribute-special-modules-along-with-roles/15098/3 "2014-04-28T12:07:37Z")

</div>

Thanks Matt, I added

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 28, 2014, 2:06pm UTC](https://forum.ansible.com/t/distribute-special-modules-along-with-roles/15098/4 "2014-04-28T14:06:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![F.L\_Jonathan\_Arana\_C](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@F.L\_Jonathan\_Arana\_C](https://forum.ansible.com/u/F.L_Jonathan_Arana_C)\
**Post date:** [April 30, 2014, 12:10pm UTC](https://forum.ansible.com/t/distribute-special-modules-along-with-roles/15098/5 "2014-04-30T12:10:02Z")

</div>

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](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 🙂

---

<div class="post-metadata">

**Author:** ![F.L\_Jonathan\_Arana\_C](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@F.L\_Jonathan\_Arana\_C](https://forum.ansible.com/u/F.L_Jonathan_Arana_C)\
**Post date:** [April 30, 2014, 12:30pm UTC](https://forum.ansible.com/t/distribute-special-modules-along-with-roles/15098/6 "2014-04-30T12:30:25Z")

</div>

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 ¢

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 30, 2014, 8:42pm UTC](https://forum.ansible.com/t/distribute-special-modules-along-with-roles/15098/7 "2014-04-30T20:42:36Z")

</div>

" but there’s no pattern / facility to acomplish that afaik, and each module does it on its own, in case it does."

try/except logic isn’t exactly complicated when they do.

This is really a topic/question for ansible-devel, FWIW.
