Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distribute ansible modules?

If someone develops an ansible role, it can be easily distributed by creating a repo on github that will be available for installation through ansible-galaxy (very clear instructions).

What about modules?

Is there a similar "supporting framework" to release an open source ansible module (e.g., bunch of python files) so that it can be easily installed by users?

like image 452
Vincenzo Pii Avatar asked Mar 11 '23 22:03

Vincenzo Pii


2 Answers

EDIT: in 2020, the best way is by creating an Ansible Collection. Collections allow for proper first-class namespacing, documentation, and distribution of all kinds of Ansible content, including roles, modules, and other plugin types.

ORIGINAL 2016 ANSWER:

Currently, the best way to do it is actually via the library directory in a galaxy role. You can still get the roles (and bundled modules) installed and usable via a requirements file without actually needing to execute anything from the role. We're also looking at ways to make roles more library-esque themselves (eg, variable/empty entry-points, not just hardcoded to tasks/main.yml).

like image 152
nitzmahone Avatar answered Mar 19 '23 02:03

nitzmahone


A role can hold modules in the library folder. To activate a module in a playbook, you need to add this role first to your playbook or as a dependency of another role. Otherwise Ansible does not know the contained modules. A role providing a module is not required to have anything else like tasks defined. Simply put your library folder inside and of course the required meta/main.yml

Since Ansible 2.0 this even works with (most) plugins, e.g. action plugins, or callback plugins can be put into the folder action_plugins or callback_plugins etc. I think connection, vars and strategy plugins do not work this way, but that is for obvious reasons. Those kind of plugins work on playbook level so they can not be loaded through roles.

like image 21
udondan Avatar answered Mar 19 '23 04:03

udondan