Skip to content
This repository was archived by the owner on Mar 24, 2020. It is now read-only.

Commit 47c08c8

Browse files
mschererbcoca
authored andcommitted
Document that plugins can be shipped in a role (#15199)
This greatly simplify the distribution of plugin on galaxy.
1 parent 60c1155 commit 47c08c8

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

docsite/rst/developing_plugins.rst

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ To change this path, edit the ansible configuration file.
118118

119119
In addition, plugins can be shipped in a subdirectory relative to a top-level playbook, in folders named the same as indicated above.
120120

121+
They can also be shipped as part of a role, in a subdirectory named as indicated above. The plugin will be availiable as soon as the role
122+
is called.
123+
121124
.. seealso::
122125

123126
:doc:`modules`

docsite/rst/playbooks_roles.rst

+14-4
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,13 @@ The resulting order of execution would be as follows::
330330
.. note::
331331
Variable inheritance and scope are detailed in the :doc:`playbooks_variables`.
332332

333-
Embedding Modules In Roles
334-
``````````````````````````
333+
Embedding Modules and Plugins In Roles
334+
``````````````````````````````````````
335335

336336
This is an advanced topic that should not be relevant for most users.
337337

338-
If you write a custom module (see :doc:`developing_modules`) you may wish to distribute it as part of a role. Generally speaking, Ansible as a project is very interested
339-
in taking high-quality modules into ansible core for inclusion, so this shouldn't be the norm, but it's quite easy to do.
338+
If you write a custom module (see :doc:`developing_modules`) or a plugin (see :doc:`developing_plugins`), you may wish to distribute it as part of a role.
339+
Generally speaking, Ansible as a project is very interested in taking high-quality modules into ansible core for inclusion, so this shouldn't be the norm, but it's quite easy to do.
340340

341341
A good example for this is if you worked at a company called AcmeWidgets, and wrote an internal module that helped configure your internal software, and you wanted other
342342
people in your organization to easily use this module -- but you didn't want to tell everyone how to configure their Ansible library path.
@@ -365,6 +365,16 @@ in production releases. This is not always advisable as API signatures may chan
365365
way of carrying a patch against a core module, however, should you have good reason for this. Naturally the project prefers that contributions be directed back
366366
to github whenever possible via a pull request.
367367

368+
The same mechanism can be used to embed and distribute plugins in a role, using the same schema. For example, for a filter plugin::
369+
370+
roles/
371+
my_custom_filter/
372+
filter_plugins
373+
filter1
374+
filter2
375+
376+
They can then be used in a template or a jinja template in any role called after 'my_custom_filter'
377+
368378
Ansible Galaxy
369379
``````````````
370380

0 commit comments

Comments
 (0)