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.
-
In the
code-serverfile explorer on the left, find theansible-navigator.ymlfile 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.
-
Add the editor configuration to your
ansible-navigator.ymlfile. Copy the following settings and paste them at the end of the file:editor: command: code-server {filename} console: falseSave the
ansible-navigator.ymlfile.
Task 3: Test the :open Subcommand
Now, run your test playbook again and try out the :open feature.
-
Execute your test playbook in the terminal:
ansible-navigator run ./test.yml -
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.
-
Open the task output in the editor. Now, issue the
:opensubcommand by typing:openand pressing Enter. A new tab should open withincode-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.