Lab Guide: Introduction to the ansible-navigator Environment

An introduction to the ansible-navigator tool and the code-server editor environment used in this lab.


Introduction

[ansible-navigator](https://github.com/ansible/ansible-navigator) is a textual user interface (TUI) available to Ansible Automation Platform subscribers. Introduced with Ansible Automation Platform 2, it serves as the primary interface for creating and testing Ansible automation. ansible-navigator also functions as a drop-in replacement for ansible-playbook and other ansible-* utilities.

In this lab, you will use ansible-navigator from within a web-based code editor environment called [code-server](https://github.com/cdr/code-server).

code-server is not packaged with Ansible Automation Platform and is not affiliated with Red Hat.

Task: Explore the Environment and Run a Test Playbook

Let’s get started by opening the integrated terminal and running a few commands.

  1. Open a new terminal. In the code-server interface, go to the top menu and select TerminalNew Terminal.

  2. Verify ansible-navigator installation. At the terminal prompt, run the following command to quickly test that ansible-navigator is installed and view its options:

    ansible-navigator --help
  3. Create a test playbook. Now that you know ansible-navigator is installed, create a simple playbook file named test.yml in your home directory (/home/rhel). You can do this by right-clicking in the file explorer pane on the left and selecting "New File". Paste the following content into the file:

    ---
    - name: this is just a test
      hosts: localhost
      gather_facts: false
      tasks:
        - name: ping test
          ansible.builtin.ping:

    Save the file.

  4. Run the playbook with ansible-navigator. Now, execute the playbook using ansible-navigator in standard output mode (-m stdout), which mimics the output style of ansible-playbook:

    ansible-navigator run ./test.yml -m stdout

    You should see output similar to this, indicating successful execution against localhost:

    [rhel@code-server ~]$ ansible-navigator run ./test.yml -m stdout
    
    PLAY [this is just a test] *****************************************************
    
    TASK [ping test] ***************************************************************
    ok: [localhost]
    
    PLAY RECAP *********************************************************************
    localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Next Steps

You have successfully verified the environment. Press the Next button below to proceed to the next challenge.

Troubleshooting

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