Creating and using execution environments
Create and use execution environment containers
Abstract
Preface Copy linkLink copied to clipboard!
Use execution environment builder to create consistent and reproducible containers for your Red Hat Ansible Automation Platform needs.
Providing feedback on Red Hat documentation Copy linkLink copied to clipboard!
If you have a suggestion to improve this documentation, or find an error, you can contact technical support at https://access.redhat.com to open a request.
Chapter 1. Introduction to Automation execution environments Copy linkLink copied to clipboard!
Using Ansible content that depends on non-default dependencies can be complicated because the packages must be installed on each node, interact with other software installed on the host system, and be kept in sync.
You must use the same environment during development, testing and in production. Red Hat provides execution environments for this purpose.
Automation execution environments help simplify this process and can easily be created with Ansible Builder.
Chapter 2. Builder Copy linkLink copied to clipboard!
Ansible provides an Execution Environment Utilities Collection, infra.ee_utilities. Red Hat provides execution environments for this purpose. This is a collection of roles for creating and managing images, or migrating from the older Tower virtualenvs to execution environment. Using this collection, you can automate the preparation and maintenance of Ansible execution environments.
2.1. About automation execution environments Copy linkLink copied to clipboard!
All automation in Red Hat Ansible Automation Platform runs on container images called automation execution environments. Automation execution environments create a common language for communicating automation dependencies, and offer a standard way to build and distribute the automation environment.
Red Hat provides supported execution environments for you to use in the Red Hat ecosystem catalog.
An automation execution environment should contain the following:
- Ansible Core 2.16 or later
- Python 3.11 or later
- Ansible Runner
- Ansible content collections and their dependencies
- System dependencies
2.1.1. Why use automation execution environments? Copy linkLink copied to clipboard!
With automation execution environments, Red Hat Ansible Automation Platform has transitioned to a distributed architecture by separating the control plane from the execution plane.
Keeping automation execution independent of the control plane results in faster development cycles and improves scalability, reliability, and portability across environments. Red Hat Ansible Automation Platform also includes access to Ansible content tools, making it easy to build and manage automation execution environments.
In addition to speed, portability, and flexibility, automation execution environments provide the following benefits:
- They ensure that automation runs consistently across multiple platforms and make it possible to incorporate system-level dependencies and collection-based content.
- They give Red Hat Ansible Automation Platform administrators the ability to provide and manage automation environments to meet the needs of different teams.
- Automation execution environmentss enable automation teams to define, build, and update their automation environments themselves. System administrators can provide execution environments, but each organization administrator can also provide their own.
- They allow automation to be easily scaled and shared between teams by providing a standard way of building and distributing the automation environment.
Chapter 3. Using Ansible Builder Copy linkLink copied to clipboard!
Ansible Builder is a command line tool that automates the process of building automation execution environments by using metadata defined in various Ansible Collections or created by the user.
You must build an execution environment before you can create it using automation controller. After building it, you must push it to a repository (such as quay) and then, when creating an execution environment in the UI with automation controller, you must point to that repository to use it in Ansible Automation Platform to use it, for example, in a job template.
3.1. Why use Ansible Builder? Copy linkLink copied to clipboard!
With Ansible Builder, you can easily create a customizable automation execution environments definition file that specifies the content you want included in your automation execution environments such as Ansible Core, Python, Collections, third-party Python requirements, and system level packages. This enables you to fulfill all of the necessary requirements and dependencies to get jobs running.
3.2. Installing Ansible Builder Copy linkLink copied to clipboard!
Install Ansible Builder to create custom execution environments that contain the dependencies and collections required for your automation content. You need a valid Red Hat subscription and Podman installed on your RHEL system
Prerequisites
- You have valid subscriptions attached on the host. Doing so enables you to access the subscription-only resources needed to install ansible-builder, and ensures that the necessary repository for ansible-builder is automatically enabled. See Attaching your Red Hat Ansible Automation Platform subscription for more information.
- You have installed the Podman container runtime.
You have valid subscriptions attached on the host. Doing so allows you to access the subscription-only resources needed to install
ansible-builder, and ensures that the necessary repository foransible-builderis automatically enabled. See Attaching your Red Hat Ansible Automation Platform subscription for more information.NoteTo install the developer tools without consuming a valid Red Hat Ansible Automation Platform managed node entitlement you can use MCT4589–Red Hat Ansible Developer, Standard (10 Managed Nodes), which is free. This subscription is for enabling users of Ansible Automation Platform. This subscription requires the approval of Ansible Business Unit.
Procedure
Run the following command to install Ansible Builder and activate your Ansible Automation Platform repo:
dnf install --enablerepo=ansible-automation-platform-2.5-for-rhel-9-x86_64-rpms ansible-builder
# dnf install --enablerepo=ansible-automation-platform-2.5-for-rhel-9-x86_64-rpms ansible-builderCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.3. Build an execution environment in a disconnected environment Copy linkLink copied to clipboard!
Creating execution environments for Ansible Automation Platform is a common task which works differently in disconnected environments. When building a custom execution environment, the ansible-builder tool defaults to downloading content from the following locations on the internet:
- Red Hat Automation hub (console.redhat.com) or Ansible Galaxy (galaxy.ansible.com) for any Ansible content collections added to the execution environment image.
- PyPI (pypi.org) for any python packages required as collection dependencies.
- RPM repositories such as the RHEL or UBI repositories (cdn.redhat.com) for adding or updating RPMs to the execution environment image, if needed.
-
registry.redhat.iofor access to the base container images.
Building an execution environment image in a disconnected environment requires mirroring content from these locations. For information about importing collections from Ansible Galaxy or automation hub into a private automation hub, see Importing an automation content collection in automation hub .
Mirrored PyPI content once transferred into the disconnected network can be made available by using a web server or an artifact repository such as Nexus. The RHEL and UBI repository content can be exported from an internet-facing Red Hat Satellite Server, copied into the disconnected environment, then imported into a disconnected Satellite so it is available for building custom execution environments. See ISS Export Sync in an Air-Gapped Scenario for details.
The default base container image, ee-minimal-rhel8, is used to create custom execution environment images and is included with the bundled installer. This image is added to the private automation hub at install time.
If a different base container image such as ee-minimal-rhel9 is required, it must be imported to the disconnected network and added to the private automation hub container registry.
Once all of the prerequisites are available on the disconnected network, the ansible-builder command can be used to create custom execution environment images.
3.4. Building a definition file Copy linkLink copied to clipboard!
You can use Ansible Builder to create an execution environment. Building a new execution environment involves a definition that specifies which content you want to include in your execution environment, such as collections, Python requirements, and system-level packages.
After you install Ansible Builder, you can create a definition file that Ansible Builder uses to create your automation execution environment image. Ansible Builder makes an automation execution environment image by reading and validating your definition file, then creating a Containerfile, and finally passing the Containerfile to Podman, which then packages and creates your automation execution environment image. The definition file that you create must be in YAML format, with a .yaml or .yml extension, and contain different sections. The default definition filename, if not provided, is execution-environment.yml. For more information on the parts of a definition file, see Breakdown of definition file content.
The following is an example of a version 3 definition file. Each definition file must specify the major version number of the Ansible Builder feature set it uses. If not specified, Ansible Builder defaults to version 1, making most new features and definition keywords unavailable.
- Lists default values for build arguments.
- Specifies the location of various requirements files.
- Specifies the base image to be used. Red Hat support is only provided for the redhat.registry.io base image.
- Specifies options that can affect builder runtime functionality.
- Commands for additional custom build steps.
Additional resources
3.5. Creating the custom execution environment definition Copy linkLink copied to clipboard!
When you have installed Ansible Builder, use the following steps to create your custom execution environment.
Procedure
Create a directory to store your custom execution environment build artifacts. Any new files created with the following steps are created under this directory.
mkdir $HOME/custom-ee $HOME/custom-ee/files cd $HOME/custom-ee/
$ mkdir $HOME/custom-ee $HOME/custom-ee/files $ cd $HOME/custom-ee/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an
execution-environment.ymlfile that defines the requirements for your custom execution environment.NoteVersion 3 of the execution environment definition format is required, so ensure the
execution-environment.ymlfile containsversion: 3explicitly before continuing.- Override the base image to point to the minimal execution environment available in your private automation hub.
Define the additional build files needed to point to any disconnected content sources that will be used in the build process. Your custom
execution-environment.ymlfile should look similar to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Create an
ansible.cfgfile under thefiles/subdirectory that points to your private automation hub.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
pip.conffile under thefiles/subdirectory which points to the internal PyPI mirror (a web server or something like Nexus):cat files/pip.conf [global] index-url = https://<pypi_mirror_fqdn>/ trusted-host = <pypi_mirror_fqdn>
$ cat files/pip.conf [global] index-url = https://<pypi_mirror_fqdn>/ trusted-host = <pypi_mirror_fqdn>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: If you use a
bindep.txtfile to add RPMs the custom execution environment, create acustom.repofile under thefiles/subdirectory that points to your disconnected Satellite or other location hosting the RPM repositories. If this step is necessary, uncomment the steps in the exampleexecution-environment.ymlfile that correspond with thecustom.repofile.The following example is for the UBI repositories. Other local repositories can be added to this file as well. The URL path might need to change depending on where the mirror content is located on the web server.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the CA certificate used to sign the private automation hub web server certificate. If the private automation hub uses self-signed certificates provided by the installer:
-
Copy the file
/etc/pulp/certs/pulp_webserver.crtfrom your private automation hub and name ithub-ca.crt. -
Add the
hub-ca.crtfile to thefiles/subdirectory.
-
Copy the file
If the private automation hub uses user-provided certificates signed by a certificate authority:
-
Make a copy of that CA certificate and name it
hub-ca.crt. -
Add the
hub-ca.crtfile to thefiles/`subdirectory.
-
Make a copy of that CA certificate and name it
When you have completed the preceding steps, create your python
requirements.txtand ansible collectionrequirements.ymlfiles, with the content needed for your custom execution environment image.NoteAny required collections must already be uploaded into your private automation hub.
The following files should exist under the
custom-ee/directory, withbindep.txtandfiles/custom.repobeing optional:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.6. Building the automation execution environment image Copy linkLink copied to clipboard!
When you have created a definition file, you can proceed to build an automation execution environment image.
When building an execution environment image, it must support the architecture that Ansible Automation Platform is deployed with.
Prerequisites
- You have created a definition file.
Procedure
To build an automation execution environment image, run the following from the command line:
ansible-builder build
$ ansible-builder buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow By default, Ansible Builder looks for a definition file named
execution-environment.ymlbut a different file path can be specified as an argument with the-fflag:For example:
ansible-builder build -f definition-file-name.yml
$ ansible-builder build -f definition-file-name.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow where definition-file-name specifies the name of your definition file.
3.7. Breakdown of definition file content Copy linkLink copied to clipboard!
You must provide a definition file to build automation execution environmentss with Ansible Builder, because it specifies the content that is included in the automation execution environment container image.
The following sections breaks down the different parts of a definition file.
3.7.1. Build arguments Copy linkLink copied to clipboard!
The build_arg_defaults section of the definition file is a dictionary whose keys can provide default values for arguments to Ansible Builder.
The following table lists values that can be used in build_arg_defaults:
| Value | Description |
|---|---|
|
| Enables the user to pass arbitrary arguments to the ansible-galaxy CLI during the collection installation phase.
For example, the |
|
|
Enables the user to pass any flags, such as |
It is generally easier (especially in a pipeline context) to customize the base image into a custom base image using podman first, and then call ansible-builder on this custom image.
The values given inside build_arg_defaults will be hard-coded into the Containerfile, so these values will persist if podman build is called manually.
If the same variable is specified in the CLI --build-arg flag, the CLI value takes higher precedence.
3.7.2. Definition dependencies Copy linkLink copied to clipboard!
You can include dependencies that must be installed into the final image in the dependencies section of your definition file.
To avoid issues with your automation execution environment image, make sure that the entries for Galaxy, Python, and system point to a valid requirements file, or are valid content for their respective file types.
3.7.2.1. Galaxy Copy linkLink copied to clipboard!
The galaxy entry points to a valid requirements file or includes inline content for the ansible-galaxy collection install -r … command.
The entry requirements.yml can be a relative path from the directory of the automation execution environment definition’s folder, or an absolute path.
The content might look like the following:
collections: - community.aws - kubernetes.core
collections:
- community.aws
- kubernetes.core
3.7.2.2. Python Copy linkLink copied to clipboard!
The python entry in the definition file points to a valid requirements file or to an inline list of Python requirements in PEP508 format for the pip install -r … command.
The entry requirements.txt is a file that installs extra Python requirements on top of what the Collections already list as their Python dependencies. It might be listed as a relative path from the directory of the automation execution environment definition’s folder, or an absolute path. The contents of a requirements.txt file should be formatted as the following example, similar to the standard output from a pip freeze command.
The content might look like the following:
3.7.2.3. System Copy linkLink copied to clipboard!
The system entry in the definition points to a bindep requirements file or to an inline list of bindep entries, which install system-level dependencies that are outside of what the collections already include as their dependencies.
The system entry can be listed as a relative path from the directory of the automation execution environment definition’s folder, or as an absolute path. At a minimum, the the collections must specify necessary requirements for [platform:rpm].
To demonstrate this, the following is an example bindep.txt file that adds the libxml2 and subversion packages to a container.
The content might look like the following:
libxml2-devel [platform:rpm] subversion [platform:rpm]
libxml2-devel [platform:rpm]
subversion [platform:rpm]
Entries from multiple collections are combined into a single file. This is processed by bindep and then passed to dnf. Only requirements with no profiles or no runtime requirements will be installed to the image.
3.7.2.4. Images Copy linkLink copied to clipboard!
The images section of the definition file identifies the base image. Verification of signed container images is supported with the podman container runtime.
The following table shows a list of values that you can use in images:
| Value | Description |
|---|---|
|
| Specifies the parent image for the automation execution environment which enables a new image to be built that is based on an existing image. This is typically a supported execution environment base image such as ee-minimal or ee-supported, but it can also be an execution environment image that you have created and want to customize further.
A
The default image is |
3.8. Additional build files Copy linkLink copied to clipboard!
You can add any external file to the build context directory by referring or copying them to the additional_build_files section of the definition file. The format is a list of dictionary values, each with a src and dest key and value.
Each list item must be a dictionary containing the following required keys:
src-
Specifies the source files to copy into the build context directory. This can be an absolute path (for example,
/home/user/.ansible.cfg), or a path that is relative to the execution environment file. Relative paths can be glob expressions matching one or more files (for example,files/*.cfg).
Absolute paths can not include a regular expression. If src is a directory, the entire contents of that directory are copied to dest.
dest-
Specifies a subdirectory path underneath the
_buildsubdirectory of the build context directory that contains the source files (for example,files/configs). This can not be an absolute path or contain..within the path. Ansible Builder creates this directory for you if it does not already exist.
3.9. Additional custom build steps Copy linkLink copied to clipboard!
You can specify custom build commands for any build phase in the additional_build_steps section of the definition file. This allows fine-grained control over the build phases.
Use the prepend_ and append_ commands to add directives to the Containerfile that run either before or after the main build steps are executed. The commands must conform to any rules required for the runtime system.
See the following table for a list of values that can be used in additional_build_steps:
| Value | Description |
|---|---|
|
| Allows you to insert commands before building the base image. |
|
| Allows you to insert commands after building the base image. |
|
| Allows you to insert before building the galaxy image. |
|
| Allows you to insert after building the galaxy image. |
|
| Allows you to insert commands before building the Python builder image. |
|
| Allows you to insert commands after building the Python builder image. |
|
| Allows you to insert before building the final image. |
|
| Allows you to insert after building the final image. |
The syntax for additional_build_steps supports both multi-line strings and lists. See the following examples:
Example 3.1. A multi-line string entry
prepend_final: | RUN whoami RUN cat /etc/os-release
prepend_final: |
RUN whoami
RUN cat /etc/os-release
Example 3.2. A list entry
append_final: - RUN echo This is a post-install command! - RUN ls -la /etc
append_final:
- RUN echo This is a post-install command!
- RUN ls -la /etc
Example 3.3. Copying arbitrary files to execution environments
The additional_build_files section enable you to add rootCA.crt to the build context directory. When this file is copied to the build context directory, it can be used in the build process. To use the file, copy it from the build context directory using the COPY directive specified in the prepend_base step of the additional_build_steps section. You can perform any action based upon the copied file, such as in this example updating dynamic configuration of CA certificates by running RUN update-ca-trust.
3.9.1. Build execution environments with environment variables Copy linkLink copied to clipboard!
The following example file specifies environment variables that might be required for the build process.
To achieve this functionality it uses the ENV variable definition in the prepend_base step of the additional_build_steps section.
—
additional_build_steps:
prepend_base:
- ENV FOO=bar
- RUN echo $FOO > /tmp/file1.txt
—
additional_build_steps:
prepend_base:
- ENV FOO=bar
- RUN echo $FOO > /tmp/file1.txt
The same environment variables can be used in the later stage of the build process.
3.9.2. Building execution environments with environment variables for Galaxy configuration Copy linkLink copied to clipboard!
Ansible Builder schema 3 enables you to perform complex scenarios such as specifying custom Galaxy configurations.
You can use this approach to pass sensitive information, such as authentication tokens, into the execution environment build without leaking them into the final execution environment image.
The following example uses Ansible Galaxy Server environment variables.
You can provide environment variables such as ANSIBLE_GALAXY_SERVER_LIST, ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_URL and ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_AUTH_URL using the ENV directive. For more information, see the Galaxy User Guide in the Ansible documentation.
For security reasons, you must not store sensitive information in ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_TOKEN. You can use the ARG directive to receive sensitive information from the user as input.
–build-args can be used to provide this information while invoking the ansible-builder command.
3.10. Updating execution environment image locations Copy linkLink copied to clipboard!
Update your execution environment image locations to use images hosted on your private automation hub. You can use execution environments from your private registry instead of the default registry.
Procedure
- Log in to Ansible Automation Platform.
Create a container registry credential for your private automation hub:
- From the navigation panel, select → → .
- Click .
Enter your credential information:
-
Name: Enter a name, such as
Private Hub Registry. - Credential Type: Select Container Registry.
-
Authentication URL: Enter the URL of your private automation hub, such as
https://automationhub.example.org. - Username: Enter your private automation hub username.
- Password or Token: Enter your private automation hub password or authentication token.
- Verify SSL: Clear this checkbox if your private automation hub uses self-signed certificates.
-
Name: Enter a name, such as
- Click .
Update the default execution environments to use images from your private automation hub:
- From the navigation panel, select → → .
-
Locate the Default execution environment and click
to edit it.
-
In the Image field, update the image path to point to your private automation hub, such as
automationhub.example.org/ee-supported-rhel9:latest. - In the Registry Credential field, select the container registry credential that you created.
- Click .
-
Locate the Minimal execution environment and click
to edit it.
-
In the Image field, update the image path to point to your private automation hub, such as
automationhub.example.org/ee-minimal-rhel9:latest. - In the Registry Credential field, select the container registry credential that you created.
- Click .
- Repeat these steps for any other execution environments that you want to update to use images from your private automation hub.
Verification
- From the navigation panel, select → → .
- Verify that your private automation hub execution environments appear in the list.
- Optional: Create a test job template that uses one of the new execution environments and run it to confirm that automation controller can successfully pull and use the image from your private automation hub.
Additional resources
3.11. Optional build command arguments Copy linkLink copied to clipboard!
The -t flag will tag your automation execution environment image with a specific name. For example, the following command builds an image named my_first_ee_image:
ansible-builder build -t my_first_ee_image
$ ansible-builder build -t my_first_ee_image
If you do not use -t with build, an image called ansible-execution-env is created and loaded into the local container registry.
If you have multiple definition files, you can specify which one to use by including the -f flag:
ansible-builder build -f another-definition-file.yml -t another_ee_image
$ ansible-builder build -f another-definition-file.yml -t another_ee_image
In this example, Ansible Builder uses the specifications provided in the file named another-definition-file.yml instead of the default execution-environment.yml to build an automation execution environment image named another_ee_image.
For other specifications and flags that you can use with the build command, enter ansible-builder build --help to see a list of additional options.
3.12. Containerfile Copy linkLink copied to clipboard!
After you have created your definition file, Ansible Builder reads and validates it, creates a Containerfile and container build context, and optionally passes these to Podman to build your automation execution environment image.
The container build occurs in several distinct stages: base , galaxy, builder, and final. The image build steps (along with any corresponding custom prepend_ and append_ steps defined in additional_build_steps) are:
-
During the
basebuild stage, the specified base image is (optionally) customized with components required by other build stages, including Python,pip,ansible-core, andansible-runner. The resulting image is then validated to ensure that the required components are available (as they may have already been present in the base image). Ephemeral copies of the resulting customizedbaseimage are used as the base for all other build stages. -
During the
galaxybuild stage, collections specified by the definition file are downloaded and stored for later installation during thefinalbuild stage. Python and system dependencies declared by the collections, if any, are also collected for later analysis. -
During the
builderbuild stage, Python dependencies declared by collections are merged with those listed in the definition file. This final set of Python dependencies is downloaded and built as Python wheels and stored for later installation during thefinalbuild stage. -
During the
finalbuild stage, the previously-downloaded collections are installed, along with system packages and any previously-built Python packages that were declared as dependencies by the collections or listed in the definition file.
3.13. Creating a Containerfile without building an image Copy linkLink copied to clipboard!
If you are required to use shared container images built in sandboxed environments for security reasons, you can create a shareable Containerfile.
ansible-builder create
$ ansible-builder create
3.14. Example YAML file to build an image Copy linkLink copied to clipboard!
The 'ansible-builder' build command takes an execution environment definition as an input. It outputs the build context necessary for building an execution environment image, and then builds that image.
The image can be re-built with the build context elsewhere, and produces the same result. By default, the builder searches for a file named execution-environment.yml in the current directory.
The following example execution-environment.yml file can be used as a starting point:
In addition to producing a ready-to-use container image, the build context is preserved. This can be rebuilt at a different time or location with the tools of your choice, such as docker build or podman build.
Chapter 4. Common automation execution environment scenarios Copy linkLink copied to clipboard!
Use the following example definition files to address common configuration scenarios.
4.1. Updating the automation hub CA certificate Copy linkLink copied to clipboard!
Use this example to customize the default definition file to include a CA certificate to the additional-build-files section, move the file to the appropriate directory and, finally, run the command to update the dynamic configuration of CA certificates to allow the system to trust this CA certificate.
Prerequisites * A custom CA certificate, for example rootCA.crt.
Customizing the CA certificate using prepend_base means that the resulting CA configuration appears in all other build stages and the final image, because all other build stages inherit from the base image.
4.2. Using automation hub authentication details when building automation execution environments Copy linkLink copied to clipboard!
Use the following example to customize the default definition file to pass automation hub authentication details into the automation execution environment build without exposing them in the final automation execution environment image.
Prerequisites
-
You have created an API token, as in Retrieving the API token for your Red Hat Certified Collection and stored it in a secure location, for example in a file named
token.txt. - Define a build argument that gets populated with the automation hub API token:
export ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_TOKEN=$(cat <token.txt>)
export ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_TOKEN=$(cat <token.txt>)
Chapter 5. Publishing an automation execution environment Copy linkLink copied to clipboard!
Publish and customize your execution environment images. This procedure guides users in adding custom content, such as a collection, to an existing execution environment image like ee-minimal.
5.1. Customizing an existing automation execution environments image Copy linkLink copied to clipboard!
Ansible Controller includes the following default execution environments:
Minimal-ansible-automation-platform-25Includes the latest Ansible-core 2.16 release along with Ansible Runner, but does not include collections or other content. Ansible-automation-platform-24 Includes the Ansible-core 2.15 release along with Ansible Runner, but does not include collections or other content.While supported execution environments cover many automation prerequisites, minimal execution-environments are the recommended basis for your own custom images, to keep full control over dependencies and their versions.
-
EE Supported- Minimal, plus all Red Hat-supported collections and dependencies
While these environments cover many automation use cases, you can add additional items to customize these containers for your specific needs. The following procedure adds the kubernetes.core collection to the ee-minimal default image:
Procedure
Log in to
registry.redhat.iousing Podman:podman login -u="[username]" -p="[token/hash]" registry.redhat.io
$ podman login -u="[username]" -p="[token/hash]" registry.redhat.ioCopy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that you can pull the required automation execution environment base image:
podman pull registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel8:latest
podman pull registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel8:latestCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure your Ansible Builder files to specify the required base image and any additional content to add to the new execution environment image.
For example, to add the Kubernetes Core Collection from Galaxy to the image, use the Galaxy entry:
collections: - kubernetes.core
collections: - kubernetes.coreCopy to Clipboard Copied! Toggle word wrap Toggle overflow - For more information about definition files and their content, see the Breakdown of definition file content section.
In the execution environment definition file, specify the original
ee-minimalcontainer’s URL and tag in theEE_BASE_IMAGEfield. In doing so, your finalexecution-environment.ymlfile appears similar to the following:Example 5.1. A customized
execution-environment.ymlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteSince this example uses the community version of
kubernetes.coreand not a certified collection from automation hub, we do not need to create anansible.cfgfile or reference that in our definition file.Build the new execution environment image by using the following command:
ansible-builder build -t [username]/new-ee
$ ansible-builder build -t [username]/new-eeCopy to Clipboard Copied! Toggle word wrap Toggle overflow where
[username]specifies your username, andnew-eespecifies the name of your new container image.NoteIf you do not use
-twithbuild, an image calledansible-execution-envis created and loaded into the local container registry.Use the
podman imagescommand to confirm that your new container image is in that list:The following shows the output of a 'podman images' command with the image
new-ee.REPOSITORY TAG IMAGE ID CREATED SIZE localhost/new-ee latest f5509587efbb 3 minutes ago 769 MB
REPOSITORY TAG IMAGE ID CREATED SIZE localhost/new-ee latest f5509587efbb 3 minutes ago 769 MBCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify that the collection is installed:
podman run [username]/new-ee ansible-doc -l kubernetes.core
$ podman run [username]/new-ee ansible-doc -l kubernetes.coreCopy to Clipboard Copied! Toggle word wrap Toggle overflow Tag the image for use in your automation hub:
podman tag [username]/new-ee [automation-hub-IP-address]/[username]/new-ee
$ podman tag [username]/new-ee [automation-hub-IP-address]/[username]/new-eeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Log in to your automation hub using Podman:
NoteYou must have
adminor appropriate container repository permissions for automation hub to push a container. For more information, see Manage containers in private automation hub.podman login -u="[username]" -p="[token/hash]" [automation-hub-IP-address]
$ podman login -u="[username]" -p="[token/hash]" [automation-hub-IP-address]Copy to Clipboard Copied! Toggle word wrap Toggle overflow Push your image to the container registry in automation hub:
podman push [automation-hub-IP-address]/[username]/new-ee
$ podman push [automation-hub-IP-address]/[username]/new-eeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Pull your new image into your automation controller instance:
- Go to automation controller.
- From the navigation panel, select → → .
- Click .
Enter the appropriate information then click to pull in the new image.
NoteIf your instance of automation hub is password or token protected, ensure that you have the appropriate container registry credential set up.
Chapter 6. Populating your private automation hub container registry Copy linkLink copied to clipboard!
By default, private automation hub does not include automation execution environments. To populate your container registry, you must push an execution environment to it.
6.1. Uploading the custom execution environment to the private hub Copy linkLink copied to clipboard!
Before the new execution environment image can be used for automation jobs, it must be uploaded to the private automation hub.
Procedure
First, verify that the execution environment image can be seen in the local podman cache:
podman images --format "table {{.ID}} {{.Repository}} {{.Tag}}" IMAGE ID REPOSITORY TAG b38e3299a65e private-hub.example.com/custom-ee latest 8e38be53b486 private-hub.example.com/ee-minimal-rhel8 latest$ podman images --format "table {{.ID}} {{.Repository}} {{.Tag}}" IMAGE ID REPOSITORY TAG b38e3299a65e private-hub.example.com/custom-ee latest 8e38be53b486 private-hub.example.com/ee-minimal-rhel8 latestCopy to Clipboard Copied! Toggle word wrap Toggle overflow Then log in to the private automation hub’s container registry and push the image to make it available for use with job templates and workflows:
podman login private-hub.example.com -u admin Password: Login Succeeded! podman push private-hub.example.com/custom-ee:latest
$ podman login private-hub.example.com -u admin Password: Login Succeeded! $ podman push private-hub.example.com/custom-ee:latestCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Use the following workflow to populate your private automation hub remote registry:
- Pull execution environments for use in automation hub
- Tag execution environment for use in automation hub
- Push an execution environment to private automation hub
- Set up your container repository
- Add a README to your container repository
- Provide access to your automation execution environmentss
- Tag container images
- Create a credential
- Pulling images from a container repository
- Pull an image
- Sync images from a container repository
Appendix A. Automation execution environments precedence Copy linkLink copied to clipboard!
Project updates always use the control plane automation execution environments by default, however, jobs use the first available automation execution environments as follows:
-
The
execution_environmentdefined on the template (job template or inventory source) that created the job. -
The
default_environmentdefined on the project that the job uses. -
The
default_environmentdefined on the organization of the job. -
The
default_environmentdefined on the organization of the inventory the job uses. -
The current
DEFAULT_EXECUTION_ENVIRONMENTsetting (configurable atapi/v2/settings/system/) -
Any image from the
GLOBAL_JOB_EXECUTION_ENVIRONMENTSsetting. - Any other global execution environment.
If more than one execution environment fits a criteria (applies for 6 and 7), the most recently created one is used.
Chapter 7. Open Source license Copy linkLink copied to clipboard!
Apache license
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
- You must give any other recipients of the Work or Derivative Works a copy of this License; and
- You must cause any modified files to carry prominent notices stating that You changed the files; and
- You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
- If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS