Ansible Builder
Ansible Builder is a command-line utility for configuring and building portable, consistent, and customized Ansible control nodes, known as Execution Environments, packaged as containers by Podman or Docker. These Execution Environments are used with Ansible Automation Platform components like AWX or Ansible Controller, Ansible Navigator, or for local development. The current version is 3.1.1, and it maintains an active release cadence with significant updates between major versions, especially in its definition schema.
Warnings
- breaking Ansible Builder 3.x introduced major changes to the execution environment definition file schema. Older `execution-environment.yml` files (schema versions 1 and 2) are not compatible and will likely cause errors or unexpected behavior if not updated to version 3.
- deprecated Execution environment schema versions 1 and 2 are deprecated and are scheduled to be removed in Ansible Builder 3.3. Using these older versions will emit warnings and require migration in future releases.
- gotcha Ansible Builder requires RPM-based container images (e.g., CentOS Stream, Rocky Linux) that use `dnf` or `microdnf`. Non-RPM-based distributions (such as Debian, Ubuntu, or Alpine) are not supported as base images and will fail to build.
- gotcha Ansible Builder 3.1 significantly changed how Python and system requirements are handled, moving towards strict PEP 508 compliance for Python `requirements.txt`. Non-compliant lines will cause warnings and may lead to unexpected dependency resolution issues, or silent removal if `pip` versions are older. Dependency sanitization is no longer performed by `ansible-builder` itself.
- gotcha When using `additional_build_files` with symlinks in an execution environment definition, Ansible Builder 3.2 changed its behavior. Previously, it dereferenced symlinks, copying the target file. Now, it copies the symlink itself. If the symlink's target doesn't exist, this previously resulted in an error, which is now avoided by copying the symlink.
Install
-
pip install ansible-builder -
sudo dnf install ansible-builder
Quickstart
# 1. Create an execution-environment.yml file: # version: 3 # dependencies: # galaxy: requirements.yml # python: requirements.txt # system: bindep.txt # # 2. Create requirements.yml (for Ansible collections): # collections: # - community.general # # 3. Create requirements.txt (for Python packages): # ansible-lint # # 4. Create bindep.txt (for system-level packages): # git [platform:rpm] # # 5. Build the Execution Environment image: ansible-builder build --tag my-execution-environment --verbosity 1