Skip to content

Commit dea01a9

Browse files
Correct information about plugin enabling (#1760) (#1871)
* Correct information about plugin enabling * Apply suggestions from code review Co-authored-by: Don Naro <[email protected]> --------- Co-authored-by: Don Naro <[email protected]> (cherry picked from commit 1500fc2) Co-authored-by: Brian Coca <[email protected]>
1 parent 62e75ee commit dea01a9

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

docs/docsite/rst/dev_guide/developing_locally.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ Ansible automatically loads all plugins from certain directories adjacent to you
137137

138138
Roles contained in collections cannot contain any plugins. All plugins in a collection must live in the collection ``plugins`` directory tree. All plugins in that tree are accessible to all roles in the collection. If you are developing new plugins, we recommend distributing them in :ref:`collections <developing_collections>`, not in roles.
139139

140+
.. warning::
141+
142+
Some plugin types are needed early during Ansible execution, such as callbacks, inventory, and cache. These plugin types cannot be loaded dynamically and must exist in configured paths or be referenced by FQCN in configuration.
143+
140144
.. _ansible.legacy.custom:
141145

142146
Using ``ansible.legacy`` to access custom versions of an ``ansible.builtin`` module

docs/docsite/rst/plugins/cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ If the cache plugin is in a collection use the fully qualified name:
3838
[defaults]
3939
fact_caching = namespace.collection_name.cache_plugin_name
4040
41-
To enable a custom cache plugin, save it in a ``cache_plugins`` directory adjacent to your play, inside a role, or in one of the directory sources configured in :ref:`ansible.cfg <ansible_configuration_settings>`.
41+
To enable a custom cache plugin, save it in one of the directory sources configured in :ref:`ansible.cfg <ansible_configuration_settings>` or in a collection and then reference it by FQCN.
4242

4343
You also need to configure other settings specific to each plugin. Consult the individual plugin documentation or the Ansible :ref:`configuration <ansible_configuration_settings>` for more details.
4444

docs/docsite/rst/plugins/callback.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The :ref:`say <say_callback>` callback responds with a computer-synthesized spee
2323
Enabling callback plugins
2424
-------------------------
2525

26-
You can activate a custom callback by either dropping it into a ``callback_plugins`` directory adjacent to your play, inside a role, or by putting it in one of the callback directory sources configured in :ref:`ansible.cfg <ansible_configuration_settings>`.
26+
You can activate a custom callback, depending on it's ``NEEDS_ENABLED`` property, by either dropping it into one of the callback directory sources configured in :ref:`ansible.cfg <ansible_configuration_settings>` or in a collection and referencing it in configuration by FQCN.
2727

2828
Plugins are loaded in alphanumeric order. For example, a plugin implemented in a file named `1_first.py` would run before a plugin file named `2_second.py`.
2929

docs/docsite/rst/plugins/inventory.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ Or, if it is a local plugin, perhaps stored in the path set by :ref:`DEFAULT_INV
3636
3737
[inventory]
3838
enable_plugins = host_list, script, auto, yaml, ini, toml, my_plugin
39-
39+
4040
If you use a plugin that supports a YAML configuration source, make sure that the name matches the name provided in the ``plugin`` entry of the inventory source file.
41+
For other plugins you must either save it in one of the directory sources configured in :ref:`ansible.cfg <ansible_configuration_settings>` and enable it or add to a collection and then reference it by FQCN.
4142

4243
.. _using_inventory:
4344

docs/docsite/rst/plugins/vars.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The :ref:`host_group_vars <host_group_vars_vars>` plugin shipped with Ansible en
1818
Enabling vars plugins
1919
---------------------
2020

21-
You can activate a custom vars plugin by either dropping it into a ``vars_plugins`` directory adjacent to your play, inside a role, or by putting it in one of the directory sources configured in :ref:`ansible.cfg <ansible_configuration_settings>`.
21+
You can activate a custom vars plugin by either dropping it into a ``vars_plugins`` directory adjacent to your play, inside a role, or by putting it in one of the directory sources configured in :ref:`ansible.cfg <ansible_configuration_settings>`. For a vars plugin to run during inventory build you cannot enable it in a play or role as these are not loaded until later. If they are only going to run at task execution, there are no limitations on where they are provided.
2222

2323
Most vars plugins are disabled by default. To enable a vars plugin, set ``vars_plugins_enabled`` in the ``defaults`` section of :ref:`ansible.cfg <ansible_configuration_settings>` or set the ``ANSIBLE_VARS_ENABLED`` environment variable to the list of vars plugins you want to execute. By default, the :ref:`host_group_vars <host_group_vars_vars>` plugin shipped with Ansible is enabled.
2424

0 commit comments

Comments
 (0)