This document provides a comprehensive guide for creating a custom Execution Environment (EE) using ansible-builder
. Follow these steps to streamline your workflow and ensure a successful build.
- System Requirements:
- Python installed.
ansible-builder
installed.- A container runtime such as Docker or Podman.
- Resources:
- Access to YAML files from the Gist repository.
Ensure all dependencies are installed and configured prior to proceeding.
sudo dnf update -y
sudo dnf install python3
Set up a Python virtual environment for running Ansible:
Create ~/venv/ansible/requirements.txt
with the following content:
autopep8
ansible-core
ansible-builder
ansible-lint
ansible-navigator
flake8
yamllint
pytest
pytest-xdist
Run the following commands:
python3 -m venv ~/venv/ansible
source ~/venv/ansible/bin/activate
python3 -m pip install -r ~/venv/ansible/requirements.txt
Clone the GitHub Gist to your local system:
git clone https://gist.github.com/CaptainStealthy/6c54a5ed3ba66e9d7ee87481e4e178c2
cd 6c54a5ed3ba66e9d7ee87481e4e178c2
This repository contains all necessary configuration files.
Create a working directory for your custom EE. If using a Git repository, add the context
folder to your .gitignore
file.
Add the following files, included in the Gist, to the working directory:
execution-environment.yml
requirements.txt
requirements.yml
Use the ansible-builder
tool to build the EE image:
ansible-builder build -f execution-environment.yml -t custom-ee:latest
podman images
Launch a container from the custom EE image to test its configuration:
podman run -it custom-ee:latest bash
Inside the container, confirm the presence of installed Ansible collections:
ansible-galaxy collection list
Log in to your container registry:
podman login https://<container registry>/ # For Podman
podman tag custom-ee:latest <container registry>/custom-ee:latest
podman push <container registry>/custom-ee:latest
- Navigate to the Execution Environments section.
- Create a new EE and specify the image URL:
<container registry>/custom-ee:latest
(or your Docker registry URL). - Test the EE by running a job template.
Remove the local image to free up space:
podman rmi custom-ee:latest # or docker rmi custom-ee:latest
Delete any temporary build artifacts:
rm -rf context/ # or specific build directories
This documentation ensures a smooth process for creating, testing, and deploying a custom Execution Environment. Tailor the steps and files to meet your specific needs and environment.