Home > Storage > PowerMax and VMAX > Storage Admin > Dell PowerMax: Ansible Modules Best Practices > Creating Ansible execution environments using Ansible Builder
Ansible can also be installed in a container environment. With Ansible Builder, you can create reproducible, self-contained environments as container images that can be run as Ansible execution environments.
Creating an execution environment requires an optional Python package called Ansible-builder that helps users create their own Ansible execution environments as containers. An organization can build up a repository of execution environment images for use with their playbook libraries from multiple different vendors, to reduce complexity and eliminate any dependency clashes.
Figure 49 shows the install for the Ansible-builder package using the Python package installer pip.
To create an execution environment, create three files:
The file execution-environment.yml describes the setup and dependencies from Ansible Galaxy. It also points to any Python requirements in requirements.txt.
Note: execution-environment.yml has a version key that should be incremented when you generate newer versions of your execution environment. You can copy the Ansible.cfg file from Ansible GitHub and make any changes required for your environment.
Figure 51 shows a sample requirements.yml, which describes the Ansible collections to be installed. When the execution environment is built, any collections and roles are automatically installed from Ansible Galaxy and are available for use in playbooks that are run in this environment.
Figure 52 shows a sample requirements.txt file that lists the Python packages to be installed. The Galaxy website and GitHub provide details about the Python package requirements for the collections.
Once the requirements.yml, requirements.txt, and execution environment.yml have been created, create the execution environment, as shown in Figure 53. By default, the ansible-builder command looks for a file named execution-environment.yml in the current directory; if you have named this file something else, you must specify the correct switch and filename on the command options.
Once the execution environment has been created, run the build command for podman or Docker to create the execution environment container image, as shown in Figure 54. This command must be run from the context directory created by the Ansible-builder command.
After the image is built and in the local registry, you can run the container and verify that everything is installed as expected.
Figure 55 shows the Ansible execution environment running with interactive terminal. Ansible-galaxy list shows the collections installed, and pip list shows that the Python dependencies were installed as expected.
This environment is ready to run playbooks or to be distributed to a container registry to be used on demand.
You can run playbooks with the execution environment as follows:
podman run --rm -e RUNNER_PLAYBOOK=/PowerMax/BasicPlaybooks/1.Provision_Host.yml --privileged --mount type=bind,source=/PowerMax,target=/PowerMax localhost/dellemc_ee_v1
Note: Running playbooks with the execution environment requires you to mount the playbooks directory as part of the run. Using Ansible Automation Controller/AWX will handle this piece for you automatically. For more information, see Working with Ansible Automation Controller/AWX.