Sunday, July 12, 2026

Ansible_9 Automation Execution Environment (EE)_latest

 What are execution environment,


All jobs with AAP are executed within containers, also known as Execution Environments, as a way to isolate jobs from the host system.
They contains the Ansble tools, collections, and roles and software librariers needed for your automation content. This is to reduce complexity and ensure that jobs run consistently across different systems.

Execution environments provide a standardized environment for running Ansible playbooks, making it easier to manage dependencies and avoid conflicts with the host system's configuration.


To create a custom execution environment, you can use Ansible Builder.
Ansible Builder allows you to define the necessary dependencies, collections, and roles required for your automation tasks. It helps you create a reproducible and portable execution environment that can be shared across different systems and teams.

Ansible Builder
Ansible Builder is a tool that allows you to create custom execution environments for Ansible Automation Platform (AAP). It helps you define the necessary dependencies, collections, and roles required for your automation tasks. By using Ansible Builder, you can create a reproducible and portable execution environment that can be shared across different systems and teams.

# ansible-builder --version
Creating custom execution environments
# mkdir -p my_execution_env; cd my_execution_env ; mkdir files; cd files ; touch ansible.cfg

The ansible.cfg file will contain information what AutomationHub Servers, we woule like to download collections from. You can also specify other configuration options as needed.


cat ansible.cfg
[galaxy]
server_list = automation_hub, ansible-galaxy
[galaxy_server.automation_hub]
url=https://automationhub.example.com/api/galaxy/v3/
token=<your_token_here>
validate_certs=False

[galaxy_server.ansible-galaxy]
url=https://galaxy.ansible.com/api/
token=<your_token_here>
validate_certs=False

# tocuch execution-environment.yml # also know as build definition file
The execution-environment.yml file will define the base image and build steps, any additional dependencies, collections, or roles that you want to include in your custom execution environment. This file is used by Ansible Builder to build the execution environment. # Essentially, everyting we need for creating the execution environment.

vi execution-environment.yml
---
version: 3
build_arg_defaults:
EE_BASE_IMAGE: "quay.io/ansible/ansible-runner:latest"
ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: "--ignore-certs"
dependencies:
galaxy: requirements.yml
galaxy:
collections:
- name: ansible.posix
version: "1.5.0"
- name: community.general
version: "6.4.0"
python: requirements.txt
python:
- boto3
- botocore
- boto
- boto3-stubs
system: bind-utils, git, openssh-clients
images:
base_image: "quay.io/ansible/ansible-runner:latest"

additional_build_steps:
prepend:
- RUN echo "Custom build step: Installing additional packages"
- RUN yum install -y jq

optional:
labels:
com.example.description: "Custom Execution Environment for Ansible Automation Platform"
com.example.version: "1.0.0"
options:
build_arg_defaults:
EE_BASE_IMAGE: "quay.io/ansible/ansible-runner:latest"
ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: "--ignore-certs"

# podman login quay.io
# podman login automationhub.example.com


Building the execution environment
Once you have defined your execution-environment.yml and ansible.cfg files, you can build the custom execution environment using the ansible-builder command. This will create a container image that includes all the necessary dependencies, collections, and roles specified in your configuration files.
# ansible-builder create -v 3 # this step is optional, it will create a new execution environment based on the execution-environment.yml file and the ansible.cfg file. It will also create a requirements.yml file that lists all the collections and roles that are included in the execution environment.

# tree context

# ansible-builder build -f execution-environment.yml -t my_custom_execution_env:latest -v 3 --no-cache
# podman image ls


# podman login quay.io --tls-verify=false


No comments:

Post a Comment