Ansible Automation Platform's Execution Environments offer a robust and efficient solution for managing automation workflows. By encapsulating playbook dependencies within a containerized environment, these environments ensure consistency and reproducibility across deployments, while also preventing conflicts with the underlying system's packages. This approach not only streamlines automation processes but also enhances security by isolating playbook execution, mitigating potential risks associated with dependency conflicts or vulnerabilities.
Before installing ansible-builder, confirm that the system has access to the required repositories. Once confirmed, proceed with the installation of ansible-builder and podman by running the command below:
[archy@ansible ~]$ sudo dnf -y --refresh install ansible-builder podman
Now, we'll create the execution-environment.yml file that defines the configuration for our Ansible Execution Environment. To keep the home-directory organized, we'll use a temporary directory for building this environment:
[archy@ansible ~]$ mkdir -p -m 700 ~/temp
[archy@ansible ~]$ cd ~/temp
[archy@ansible ~]$ cat << EOF > execution-environment.yml
---
version: 1
ansible_config: ansible.cfg
build_arg_defaults:
EE_BASE_IMAGE: registry.redhat.io/ansible-automation-platform-25/ee-minimal-rhel9:latest
EE_BUILDER_IMAGE: registry.redhat.io/ansible-automation-platform/ansible-builder-rhel9:latest
dependencies:
galaxy: requirements.yml
python: requirements.txt
system: bindep.txt
EOF
While dependencies are optional, any specified dependencies must be included in the build. This execution environment requires specific collections, Python packages, and system packages to function correctly. To manage these, we'll create the necessary dependency files and include them in our build process:
[archy@controller ~]$ cat << EOF > requirements.yml
---
collections:
- name: ansible.posix
- name: ansible.utils
- name: community.general
EOF
[archy@ansible ~]$ cat << EOF > requirements.txt
pymongo
kubernetes
ipapython
paramiko
netaddr
EOF
[archy@controller ~]$ cat << EOF > bindep.txt
rsync
EOF
[archy@ansible ~]$ ansible-builder create
[archy@controller ~]$ podman build -f context/Containerfile -t automationhub.archyslife.lan/custom/ee-custom-rhel9:$(date +%F) --arch amd64 --pull=true context
[archy@controller ~]$ podman push automationhub.archyslife.lan/custom/ee-custom-rhel9:$(date +%F)
Comments
Post a Comment