Execution Environments
Ansible automation can be run in containers, using container images known as Execution Environments (EE) that act as control nodes.
An Execution Environment image contains the following packages as standard:
ansible-coreansible-runner- Python
- Ansible content dependencies
In addition to the standard packages, an EE can also contain:
- one or more Ansible collections and their dependencies
- other custom components
EE Definition File
Define at least the definition file for the Execution Environment and other files, depending on your use-case.
execution-environment.yml
---
version: 3
images:
base_image:
name: registry.redhat.io/ansible-automation-platform-26/ee-supported-rhel9:latest # (1)!
dependencies: # (2)!
galaxy: requirements.yml # (3)!
python: requirements.txt # (4)!
system: bindep.txt
- Some more useful base images:
- registry.redhat.io/ansible-automation-platform-26/ee-minimal-rhel9:latest
- ghcr.io/ansible-community/community-ee-base:latest
- ghcr.io/ansible-community/community-ee-minimal:latest
- registry.access.redhat.com/ubi9/ubi:latest
- quay.io/rockylinux/rockylinux:9
- If you want to install a specific Ansible version add this configuration under the
dependencieskey: - Instead of using a separate file, you can provide collections (and roles) as a list:
- Instead of using a separate file, you can provide the Python packages as a list:
requirements.txt
Tip
Add/install the ansible-lint package alongside the other Python dependencies!
This ensures you can use ansible-navigator lint, as well as everybody utilizing the EE does use the same version of the linter.
For more information, go to the Ansible Builder Documentation.
The requirements.* files should already be part of the project directory, add the execution-environment.yml to the project root directory as well.
Build EE image
The Builder expects the EE configuration in the current working directory with the name execution-environment.yml.
To build the EE, run this command:
Tip
Always use the -v 3 verbosity setting, this helps understanding what is done during the build process.
Definition files with a different name must be provided via the -f parameter.
The resulting container images can be viewed with the podman images command:
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/custom-ee latest 39466794b6cd 6 minutes ago 540 MB
Tip
You can also build Execution Environments with ansible-navigator, the Builder is installed alongside Navigator.
- The parameter
--ee falseseems counter-intuitive at first, but is necessary to run locally. Without it, the Navigator tries to download theghcr.io/ansible/community-ansible-dev-tools:latestimage.
Once, the EE image is built, execute it with Ansible Navigator or push it to a container registry and use it in AAP/AWX.
Possible EE build errors
During the build process, errors may occur, depending on your build environment, used base image, collections or dependencies to be installed.
The following shows some possible errors and how to mitigate them.
The build process may fail with the following error:
...
+ /usr/bin/dnf install -y gcc libssh libssh-devel python3-Cython python3-cffi python3-cryptography python3-lxml python3-pycparser python3-six python3.11-devel systemd-devel
/output/scripts/assemble: line 73: /usr/bin/dnf: No such file or directory
Error: building at STEP "RUN /output/scripts/assemble": while running runtime: exit status 127
...
This error most likely shows when using minimal base images, e.g. registry.redhat.io/ansible-automation-platform-26/ee-minimal-rhel9:latest where a lightweight dnf is used.
Solution
Adjust the package manager path.
Add the following setting to your execution-environment.yml:
The build process may fail with the following error:
This error may occur if the pip utility is not installed or can not be deduced correctly.
Solution
Define the Python Interpreter.
Get the Python Version of the base image, if already installed:
podman run -it registry.redhat.io/ansible-automation-platform-26/ee-minimal-rhel9:latest python3 --version
Add the following setting to your execution-environment.yml:
You can also define a newer Python version, but you must ensure that it can be installed with the repository settings in the container base image.
The build process may fail with the following error:
...
+ /usr/bin/python3.11 -c 'import ansible ; import ansible_runner'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ansible'
+ '[' 1 -ne 0 ']'
+ cat
**********************************************************************
ERROR - Missing Ansible or Ansible Runner for selected Python
Solution
Define ansible-core and ansible-runner in the dependencies section.
Add the following setting to your execution-environment.yml:
dependencies:
ansible_core:
package_pip: ansible-core # (1)!
ansible_runner:
package_pip: ansible-runner
- You can also define a specific version, e.g.
package_pip: ansible-core==2.16.18
The build process may fail with the following error:
This error most likely occurs when using base images like registry.access.redhat.com/ubi9/ubi:latest where no Ansible is installed yet.
Solution
Define ansible-core and ansible-runner in the dependencies section.
Add the following setting to your execution-environment.yml:
Needs the following configuration:
dependencies:
ansible_runner:
package_pip: ansible-runner
ansible_core:
package_pip: ansible-core # (1)!
- You can also define a specific version, e.g.
package_pip: ansible-core==2.16.18