Lab Guide: Using Execution Environments with ansible-navigator
A guide to configuring ansible-navigator to use an execution environment for running playbooks.
Introduction
When sharing playbooks developed locally, communicating all the dependencies (collections, roles, Python packages, system packages, etc.) can be challenging. Execution environments solve this problem by bundling all necessary dependencies into container images. These images can be easily shared, ensuring that automation executes reliably everywhere.
ansible-navigator is designed to use these execution environments seamlessly when running your playbooks.
Task 1: Enable the Execution Environment
Up to this point, ansible-navigator has been running using only the built-in modules without a specific execution environment. Let’s configure it to use the default execution environment image.
-
Modify
ansible-navigator.yml. Open theansible-navigator.ymlfile in your home directory (/home/rhel). Change theenabledsetting under theexecution-environmentblock fromfalsetotrue. The relevant part of the file should now look like this:--- ansible-navigator: execution-environment: container-engine: podman image: ee-supported-rhel8:2.0.0 enabled: true # <-- Change this line pull-policy: never # ... rest of the fileSave the file.
Task 2: Run a Playbook with the Execution Environment
Now, re-run your test playbook. ansible-navigator will detect the configuration change and use the specified execution environment.
-
Re-run your test playbook in the terminal:
ansible-navigator run ./test.ymlNotice that
ansible-navigatorrecognizes it should use an execution environment. Since the image isn’t present locally, it will automatically pull theee-supported-rhel8:2.0.0image from a container registry. (Note:ansible-navigator.ymlcan also be configured to pull images from your organization’s Private Automation Hub). -
Verify successful execution. Once the image pull is complete, your
test.ymlplaybook should execute successfully within the containerized environment.
Task 3: Inspect the Execution Environment
You can use ansible-navigator itself to inspect the contents of the execution environment you just pulled.
-
View installed collections. While still in the
ansible-navigatorTUI from the previous step (or by runningansible-navigatoragain), issue the:collectionssubcommand by typing:collectionsand pressing Enter. This will show you all the Ansible collections included within the execution environment image. -
Find module author information. While inspecting the collections list, navigate into the
ansible.utilscollection (press the corresponding number). Find thefact_diffmodule within this collection. View its details (press the corresponding number again) and locate the author information. Note the GitHub handle associated with the author. You can pressEscmultiple times to return to the main menu or exit.
Next Steps
You have successfully configured ansible-navigator to use an execution environment and inspected its contents. Press the Next button below.
Troubleshooting
If you have encountered an issue or have noticed something not quite right, please open an issue on GitHub.