Browse code

documents the use of ansible.legacy (#73942)

Alicia Cozine authored on 2021/03/26 05:36:46
Showing 1 changed files
... ...
@@ -110,11 +110,10 @@ This creates the collection directory structure.
110 110
 
111 111
 5. Update the collection README.md file to add links to any role README.md files.
112 112
 
113
-
114 113
 .. _complex_roles_in_collections:
115 114
 
116
-Migrating a role with plugins to a collection
117
-==============================================
115
+Migrating a role that contains plugins to a collection
116
+======================================================
118 117
 
119 118
 To migrate from a standalone role that has plugins to a collection role:
120 119
 
... ...
@@ -408,3 +407,21 @@ The following is an example RPM spec file that accomplishes this using this exam
408 408
   %doc %{collection_dir}/roles/*/README.md
409 409
   %license %{_pkgdocdir}/*/COPYING
410 410
   %license %{_pkgdocdir}/*/LICENSE
411
+
412
+.. _using_ansible_legacy:
413
+
414
+Using ``ansible.legacy`` to access local custom modules from collections-based roles
415
+=====================================================================================
416
+
417
+Some roles use :ref:`local custom modules <developing_locally>` that are not part of the role itself. When you move these roles into collections, they can no longer find those custom plugins. You can add the synthetic collection ``ansible.legacy`` to enable legacy behavior and find those custom plugins. Adding ``ansible.legacy`` configures your role to search the pre-collections default paths for modules and plugins.
418
+
419
+To enable a role hosted in a collection to find legacy custom modules and other plugins hosted locally:
420
+
421
+Edit the role's ``meta/main.yml`` and add the ``ansible.legacy`` collection to your collection-hosted role to enable the use of legacy custom modules and plugins for all tasks:
422
+
423
+.. code-block:: yaml
424
+
425
+   collections:
426
+     - ansible.legacy
427
+
428
+Alternatively, you can update the tasks directly by changing ``local_module_name`` to ``ansible.legacy.local_module_name``.