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.

  1. Modify ansible-navigator.yml. Open the ansible-navigator.yml file in your home directory (/home/rhel). Change the enabled setting under the execution-environment block from false to true. 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 file

    Save 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.

  1. Re-run your test playbook in the terminal:

    ansible-navigator run ./test.yml

    Notice that ansible-navigator recognizes it should use an execution environment. Since the image isn’t present locally, it will automatically pull the ee-supported-rhel8:2.0.0 image from a container registry. (Note: ansible-navigator.yml can also be configured to pull images from your organization’s Private Automation Hub).

  2. Verify successful execution. Once the image pull is complete, your test.yml playbook 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.

  1. View installed collections. While still in the ansible-navigator TUI from the previous step (or by running ansible-navigator again), issue the :collections subcommand by typing :collections and pressing Enter. This will show you all the Ansible collections included within the execution environment image.

  2. Find module author information. While inspecting the collections list, navigate into the ansible.utils collection (press the corresponding number). Find the fact_diff module 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 press Esc multiple 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.