Lab Guide: Configuring Common ansible-navigator Options

A guide to exploring and configuring common settings in ansible-navigator.yml.


Introduction

ansible-navigator aims to unify the development experience, offering many configuration options that can be customized for each developer or project via the ansible-navigator.yml file. This is useful if your projects require different execution environments or Ansible defaults. Developers can also use these settings to adapt ansible-navigator to their preferred development style and code editor.

Let’s explore some common configuration options.


Task 1: Explore the Configuration File

First, examine the existing ansible-navigator.yml configuration file.

  1. In the code-server file explorer on the left, find the ansible-navigator.yml file in your home directory (/home/rhel). Open it to view its contents. Notice the pre-configured settings related to execution environments and logging.


Task 2: Configure the Editor for the :open Subcommand

A useful feature is the ability to open the output of any ansible-navigator screen in your preferred text editor using the :open subcommand. Let’s configure this to use code-server.

  1. Add the editor configuration to your ansible-navigator.yml file. Copy the following settings and paste them at the end of the file:

      editor:
        command: code-server {filename}
        console: false

    Save the ansible-navigator.yml file.


Task 3: Test the :open Subcommand

Now, run your test playbook again and try out the :open feature.

  1. Execute your test playbook in the terminal:

    ansible-navigator run ./test.yml
  2. Navigate to a task’s output. Once the playbook finishes, inspect the play by pressing kbd:[0], then inspect the first task (Gathering Facts) by pressing kbd:[0] again.

  3. Open the task output in the editor. Now, issue the :open subcommand by typing :open and pressing Enter. A new tab should open within code-server, displaying the detailed output (facts gathered) of that task.

The :open subcommand works on any screen within the ansible-navigator TUI and can be very helpful when developing or debugging playbooks.

Next Steps

You have learned how to configure and use the :open subcommand in ansible-navigator. Press the Next button below to proceed.

Troubleshooting

If you have encountered an issue or have noticed something not quite right, please open an issue on GitHub.