| 1 |
.. |
| 2 |
Copyright (c) Ansible Project |
| 3 |
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
|
| 6 |
.. _ansible_collections.community.general.docsite.guide_ee: |
| 7 |
|
| 8 |
Execution Environment Guide |
| 9 |
=========================== |
| 10 |
|
| 11 |
`Ansible Execution Environments <https://docs.ansible.com/projects/ansible/latest/getting_started_ee/index.html>`_ |
| 12 |
(EEs) are container images that bundle ansible-core, collections, and their Python and system dependencies. |
| 13 |
They are the standard runtime for Red Hat Ansible Automation Platform and AWX, replacing the older virtualenv model. |
| 14 |
They can also be used outside of RHAAP and AWX by using `ansible-navigator <https://docs.ansible.com/projects/navigator/>`__, or by using ansible-runner directly. |
| 15 |
|
| 16 |
What runs in the EE |
| 17 |
^^^^^^^^^^^^^^^^^^^ |
| 18 |
|
| 19 |
Only **controller-side plugins** run inside the EE. Their Python and system dependencies must be installed there. |
| 20 |
This includes: lookup plugins, inventory plugins, callback plugins, connection plugins, become plugins, and filter plugins. |
| 21 |
|
| 22 |
Modules run on the managed nodes and are transferred there at runtime — their dependencies must be present on the |
| 23 |
target, not in the EE. |
| 24 |
|
| 25 |
.. note:: |
| 26 |
|
| 27 |
Modules delegated to ``localhost`` (for example, those that interact with a remote API) are an exception: |
| 28 |
they run on the controller and their dependencies must therefore be available in the EE. |
| 29 |
|
| 30 |
Why community.general does not provide EE metadata |
| 31 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 32 |
|
| 33 |
``community.general`` ships dozens of controller-side plugins covering a very broad range of technologies. |
| 34 |
Bundling the dependencies for all of them into a single EE image would almost certainly create irreconcilable |
| 35 |
conflicts — both within the collection and with other collections or tools (such as ``ansible-lint``) that |
| 36 |
share the same image. |
| 37 |
|
| 38 |
For that reason, ``community.general`` does **not** provide Python or system package dependency metadata. |
| 39 |
Users are expected to build purpose-built, minimal EEs containing only the dependencies |
| 40 |
required by the specific plugins they actually use. |
| 41 |
|
| 42 |
Finding the dependencies you need |
| 43 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 44 |
|
| 45 |
Every plugin that has external dependencies documents them in its ``requirements`` field. |
| 46 |
You can inspect those with ``ansible-doc``: |
| 47 |
|
| 48 |
.. code-block:: shell |
| 49 |
|
| 50 |
$ ansible-doc -t lookup community.general.some_lookup | grep -A 10 "REQUIREMENTS" |
| 51 |
|
| 52 |
Or browse the plugin's documentation page on `docs.ansible.com <https://docs.ansible.com/ansible/latest/collections/community/general/>`_. |
| 53 |
|
| 54 |
For example, a lookup plugin that wraps an external service might list: |
| 55 |
|
| 56 |
.. code-block:: yaml |
| 57 |
|
| 58 |
requirements: |
| 59 |
- some-python-library >= 1.2 |
| 60 |
|
| 61 |
An inventory plugin backed by a REST API might list: |
| 62 |
|
| 63 |
.. code-block:: yaml |
| 64 |
|
| 65 |
requirements: |
| 66 |
- requests |
| 67 |
- some-sdk |
| 68 |
|
| 69 |
These are the packages you need to add to your EE. |
| 70 |
|
| 71 |
Building a minimal EE with ansible-builder |
| 72 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 73 |
|
| 74 |
`ansible-builder <https://docs.ansible.com/projects/builder/en/latest/>`_ is the standard tool for creating EEs. |
| 75 |
|
| 76 |
Install it with: |
| 77 |
|
| 78 |
.. code-block:: shell |
| 79 |
|
| 80 |
$ pip install ansible-builder |
| 81 |
|
| 82 |
Create an ``execution-environment.yml`` **in your own project** — not inside ``community.general`` — |
| 83 |
that includes only the dependencies needed for the plugins you use: |
| 84 |
|
| 85 |
.. code-block:: yaml |
| 86 |
|
| 87 |
version: 3 |
| 88 |
|
| 89 |
dependencies: |
| 90 |
galaxy: |
| 91 |
collections: |
| 92 |
- name: community.general |
| 93 |
python: |
| 94 |
- some-python-library>=1.2 |
| 95 |
- requests |
| 96 |
system: |
| 97 |
- libxml2-devel [platform:rpm] |
| 98 |
|
| 99 |
images: |
| 100 |
base_image: |
| 101 |
name: ghcr.io/ansible/community-ee-base:latest |
| 102 |
|
| 103 |
Then build the image: |
| 104 |
|
| 105 |
.. code-block:: shell |
| 106 |
|
| 107 |
$ ansible-builder build -t my-custom-ee:latest |
| 108 |
|
| 109 |
.. seealso:: |
| 110 |
|
| 111 |
- `ansible-builder documentation <https://docs.ansible.com/projects/builder/en/latest/>`_ |
| 112 |
- `Building EEs with ansible-builder <https://ansible-builder.readthedocs.io/en/latest/definition/>`_ |
| 113 |
- `Issue #2968 — original request for EE requirements support <https://github.com/ansible-collections/community.general/issues/2968>`_ |
| 114 |
- `Issue #4512 — design discussion for EE support in community.general <https://github.com/ansible-collections/community.general/issues/4512>`_ |