Configure ansible-navigator and Execution Environments

AnsibleBeginner
Practice Now

Introduction

Current EX294-style workflows include ansible-navigator because it can run automation with a consistent interface and, when available, execution environments. In this LabEx RHEL 10 VM, the tool is available, and this lab uses local execution mode so the workflow is stable and fast.

In this lab, you will create ansible-navigator.yml, configure stdout mode, disable execution environments for this local VM workflow, and run a playbook with navigator.

Build a Small Navigator Project

In this step, you will create the project structure, inventory, and Ansible defaults needed by navigator. Navigator reads many of the same project files as ansible-playbook.

Create the directories and enter the project.

cd /home/labex/project
mkdir -p rhce-ansible/{inventory,playbooks}
cd rhce-ansible

Create the inventory.

cat > inventory/hosts <<'EOF'
[control]
control ansible_connection=local
EOF

This inventory uses one local host alias so the lab can focus on navigator behavior instead of SSH. The alias still matters: navigator passes the playbook to Ansible, and Ansible still resolves hosts: control through inventory.

Create ansible.cfg so both navigator and Ansible use the same inventory.

cat > ansible.cfg <<'EOF'
[defaults]
inventory = ./inventory/hosts
retry_files_enabled = False
interpreter_python = auto_silent
EOF

Keeping inventory in ansible.cfg means later ansible-navigator run commands do not need an explicit -i option. This is the first connection between the navigator workflow and the normal Ansible project defaults.

Check Navigator Availability

In this step, you will confirm that ansible-navigator is installed and see the version. Checking the tool before writing configuration makes failures easier to understand.

Before running commands in this step, return to the project directory so relative paths refer to the Ansible project.

cd /home/labex/project/rhce-ansible

Run the version command.

ansible-navigator --version

The output should show an ansible-navigator version number.

If this command works, you know the tool itself is installed before you begin debugging configuration. That separation is useful: a missing tool and a bad ansible-navigator.yml produce very different problems.

Ask navigator for help on the run subcommand.

ansible-navigator run --help | sed -n '1,12p'

The help output confirms the subcommand name and shows that navigator expects a playbook path. You do not need to memorize every option here; the goal is to know how to ask the installed tool for help.

Write ansible-navigator.yml

In this step, you will create navigator configuration. The mode: stdout setting makes navigator print normal terminal output, which is ideal for guided labs. The execution-environment.enabled: false setting keeps execution local to this RHEL 10 VM.

Before running commands in this step, return to the project directory so relative paths refer to the Ansible project.

cd /home/labex/project/rhce-ansible

Create ansible-navigator.yml.

cat > ansible-navigator.yml <<'EOF'
---
ansible-navigator:
  mode: stdout
  execution-environment:
    enabled: false
  playbook-artifact:
    enable: false
EOF

Three settings matter for this lab. mode: stdout keeps output in the terminal, execution-environment.enabled: false tells navigator to run with the local Ansible installation, and disabling playbook-artifact avoids generating extra result files that would distract from the main workflow.

Display the file to verify indentation. YAML indentation is part of the syntax.

sed -n '1,20p' ansible-navigator.yml

Check that mode, execution-environment, and playbook-artifact are nested under ansible-navigator. If one of those keys starts in the wrong column, YAML may parse a different structure than you intended.

Create a Navigator Smoke Playbook

In this step, you will write a short playbook for navigator to run. A playbook is a YAML list of plays. Each play names target hosts and tasks.

Before running commands in this step, return to the project directory so relative paths refer to the Ansible project.

cd /home/labex/project/rhce-ansible

Create playbooks/navigator-check.yml.

cat > playbooks/navigator-check.yml <<'EOF'
---
- name: Check navigator execution
  hosts: control
  gather_facts: false
  tasks:
    - name: Write navigator proof file
      ansible.builtin.copy:
        dest: /home/labex/project/rhce-ansible/navigator-proof.txt
        content: navigator ran this playbook
        mode: '0644'
EOF

The playbook writes a file under the project directory so you have visible evidence after the run. The copy module is idempotent: it changes the file only when the content or mode is different from the requested state.

Use ansible-playbook --syntax-check before running it. Syntax checks catch YAML and playbook structure mistakes without changing the host.

ansible-playbook playbooks/navigator-check.yml --syntax-check

The syntax check should print a playbook: line. It does not run tasks, but it confirms Ansible can parse the playbook before navigator executes it.

Run the Playbook with Navigator

In this step, you will run the playbook through navigator. The run subcommand executes a playbook, and the project configuration makes the output readable in this terminal.

Before running commands in this step, return to the project directory so relative paths refer to the Ansible project.

cd /home/labex/project/rhce-ansible

Run the playbook.

ansible-navigator run playbooks/navigator-check.yml

A successful recap should show failed=0. Confirm the proof file was created.

Because mode: stdout is configured, the output should look similar to a normal ansible-playbook run. Read the recap first, then inspect the proof file to connect the reported task result with a real file on disk.

cat navigator-proof.txt

Summary

You configured ansible-navigator for a local LabEx RHEL 10 workflow, wrote a valid playbook, and ran it through navigator. This gives you a repeatable execution model for later RHCE Ansible labs.