Distribute special modules along with roles

59 views
Skip to first unread message

Petros Moisiadis

unread,
Apr 28, 2014, 5:56:48 AM4/28/14
to ansible...@googlegroups.com
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.

Matt Martz

unread,
Apr 28, 2014, 7:24:35 AM4/28/14
to ansible...@googlegroups.com
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.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/535E25E0.4040106%40yahoo.gr.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
ma...@sivel.net
http://sivel.net/

Petros Moisiadis

unread,
Apr 28, 2014, 8:07:37 AM4/28/14
to ansible...@googlegroups.com

Michael DeHaan

unread,
Apr 28, 2014, 10:06:30 AM4/28/14
to ansible...@googlegroups.com
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.




"F.L. Jonathan Araña Cruz"

unread,
Apr 30, 2014, 8:10:02 AM4/30/14
to ansible...@googlegroups.com
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 :)

"F.L. Jonathan Araña Cruz"

unread,
Apr 30, 2014, 8:30:25 AM4/30/14
to ansible...@googlegroups.com
On 28/04/14 12:24, Matt Martz wrote:
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.
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 ¢



On Monday, April 28, 2014, Petros Moisiadis <erne...@yahoo.gr> wrote:
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/535E25E0.4040106%40yahoo.gr.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
ma...@sivel.net
http://sivel.net/
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Michael DeHaan

unread,
Apr 30, 2014, 4:42:36 PM4/30/14
to ansible...@googlegroups.com
" 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.




Reply all
Reply to author
Forward
0 new messages