Exploring Ansible Automation with Ansible Navigator

Exploring Ansible Automation with Ansible Navigator

Ansible has long been a cornerstone in the world of automation, offering powerful tools for managing IT infrastructure efficiently. With the introduction of Ansible Navigator, managing Ansible content has become even more intuitive and user-friendly.

What is Ansible Navigator?

Ansible Navigator is a versatile command-line tool and a text-based user interface (TUI) for creating, reviewing, running, and troubleshooting Ansible content. It provides a comprehensive set of features for managing inventories, playbooks, collections, documentation, and container images (execution environments).

Getting Started with Ansible Navigator

  1. Install the Python Package Manager:

Use your system’s package installer to install the Python 3 package manager (e.g., pip):

[root@node1 ~]# sudo dnf install python3-pip

2. Install Ansible Navigator:

Use pip to install Ansible Navigator:

[root@node1 ~]# pip3 install ansible-navigator

3. Verify Ansible Navigator:

[root@node1 ~]# ansible-navigator --help
Usage: ansible-navigator [options]

Options (global):

Download the Demo Execution-Environment Image: Note that when you launch Ansible Navigator for the first time, it triggers a one-time download of the demo execution-environment image.

Unlike other Ansible commands such as ansible-playbookansible-galaxyansible-lint, and ansible-doc, Ansible Navigator offers a comprehensive set of subcommands that cover various aspects of managing Ansible content. With Ansible Navigator, you can not only perform these tasks but also run playbooks directly on your execution environment (EE) image. This capability allows you to test your playbooks on the EE image without the need to push them to Ansible Tower (AWX) or Ansible Automation Platform (AAP), making it a valuable tool for streamlining your Ansible workflow and testing process.

Available Subcommands

Ansible Navigator provides several subcommands that allow you to perform various tasks related to managing Ansible content. Here is a list of available subcommands along with a brief description of each:

Subcommands:
{subcommand} --help
builder Build [execution environment](https://ansible.readthedocs.io/en/latest/getting_started_ee/index.html)
(container image)
collections Explore available collections
config Explore the current ansible configuration
doc Review documentation for a module or plugin
exec Run a command within an execution environment
images Explore execution environment images
inventory Explore an inventory
lint Lint a file or directory for common errors and issues
replay Explore a previous run using a playbook artifact
run Run a playbook
settings Review the current ansible-navigator settings
welcome Start at the welcome page
  1. builder: Build execution environment (container image).
  • CLI Example: ansible-navigator builder --help

To know more about Execution environment images, I have already written a blog on the same Customizing Ansible: Creating Execution Environment Images

2. collections: Explore available collections.

  • CLI Example: ansible-navigator collections --help

3. config: Explore the current Ansible configuration.

  • CLI Example: ansible-navigator config --help

4. doc: Review documentation for a module or plugin.

  • CLI Example: ansible-navigator doc --help

5. exec: Run a command within an execution environment.

  • CLI Example: ansible-navigator exec --help

6. images: Explore execution environment images.

  • CLI Example: ansible-navigator images --help

7. inventory: Explore an inventory.

  • CLI Example: ansible-navigator inventory --help

8. lint: Lint a file or directory for common errors and issues.

  • CLI Example: ansible-navigator lint --help

Running Playbook using ansible-navigator

Before executing a playbook it will pull an execution environment image if it’s not present and by default image used for running the playbook is ghcr.io/ansible/creator-ee:v0.22.0 or we can use our image as well by using an option — execution-environment-image

[root@node1 ansible]# ansible-navigator run test.yml

It will execute a playbook on the default EE image and give a high-level description of the execution.

Output of “ansible-navigator run test1.yml”

In case of failure, it will show output like this

Output of “ansible-navigator run test.yml”

Verify Execution Environment images on your machine:

[root@node1 ansible]# ansible-navigator images
Output of “ansible-navigator image”

ansible-navigator to check docs:

[root@node1 ~]# ansible-navigator doc package

Ansible Navigator is a powerful tool for managing Ansible content, offering a user-friendly interface for creating, reviewing, running, and troubleshooting automation workflows. Whether you’re new to Ansible or a seasoned user, Ansible Navigator can help streamline your automation workflows and make managing infrastructure more efficient.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top