Creating Ansible Execution Environments for Dell Technologies Storage
Mon, 11 Apr 2022 13:52:13 -0000
|Read Time: 0 minutes
Dell Technologies has been providing Ansible Collections via Ansible Galaxy and GitHub for some time. This has greatly simplified the setup of Ansible configurations so that playbooks can be run quickly. However, in some environments the need to be even more dynamic means that even this process can provide challenges. This is where ansible execution environments can help.
Ansible execution environments are self-contained container environments that provide reproducible environments as container images that can be run as needed, keeping configurations to a bare minimum. They also ensure that the storage automation environment and its dependencies can be spun up when needed, knowing that these environments are tested and have no configuration clashes with other automation environments. Here’s a great introduction to the Ansible execution environment.
Creating an execution environment is done in Python with an optional Python package called Ansible-builder that helps users create their own Ansible execution environments packaged 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. Organizations can even maintain versions of execution environments for their automation for different configurations of the same products, ensuring that what is tested and known to work will always work.
In order to create an execution environment, you will need to create three files:
- execution-environment.yml
- requirements.txt
- environment.yml
The contents and purpose of these files are as follows.
execution-environment.yml
execution-environment.yml – This YAML file describes the setup and dependencies from Ansible Galaxy. It also points to any Python requirements in requirements.txt. Here’s an example of its contents:
# sample execution-environment.yml --- version: 1 build_arg_defaults: EE_BASE_IMAGE: 'quay.io/Ansible/Ansible-runner:latest' Ansible_config: 'Ansible.cfg' dependencies: galaxy: requirements.yml python: requirements.txt
An example of the requirements.yml file is below.
# Sample requirements.yml collections: - name: dellemc.powermax version: 1.6
requirements.txt
Here is a sample requirements.txt file:
# Sample requirements.txt PyU4V==9.2.1.4
After the requirements.yml, requirements.txt and execution-environment.yml files have been created, you can go on to create the execution environment container.
To create the container, simply run the command as follows. (Note that the tag can be anything that makes sense in your environment.)
ansible-builder build –tag dellemc_ee_powermax1.6 –container-runtime podman
After the execution environment has been created, run the build command for podman or Docker to create the execution environment container image. You must run this from the context directory that was 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.
The picture above shows the Ansible execution environment running with an interactive terminal. The pip list command executed in the terminal shows all the Python dependencies installed as expected. The ansible-galaxy list command shows the collections installed.
This environment is ready to execute playbooks or to be distributed to a container registry to be used on demand.
Uploading to a container registry such as quay.io will make the container available to anyone in your organization that requires it or will make it available to tools like Ansible Automation Controller.
To upload to quay.io, follow the steps detailed here.
For additional information about getting started with Ansible, and using Ansible automation controller with Dell Technologies Storage products, see the Dell PowerMax: Ansible Modules Best Practices white paper on the PowerMax Info Hub.
With each new release of Ansible collections, we will publish a copy of the requirements.txt, requirements.yml, and execution-environment.yml files on https://github.com/dell/{{collection_name}}. We hope this will help people streamline the process of creating new execution environments. Users will create their own execution-environment.yml file and build as described, using the processes outlined here.
Author: Paul Martin, Senior Principal Technical Marketing Engineer
Twitter: @rawstorage