4

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?

Vincenzo Pii
  • 18,961
  • 8
  • 39
  • 49
  • Ansible Galaxy seems like a ghost town. I've had much better results by pulling files in from different repos. This is especially true with core modules, as the backlog for fixes to get published is many months. – tedder42 Jun 21 '16 at 00:38

2 Answers2

6

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).

nitzmahone
  • 13,720
  • 2
  • 36
  • 39
  • Beware that with Ansible 2.9 it is not possible to install collections from private repos (in contrast to roles). The documentation includes this only for the next version (Ansible 3?) – kap May 06 '21 at 20:30
1

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.

udondan
  • 57,263
  • 20
  • 190
  • 175