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.
-
Open a new terminal. In the
code-serverinterface, go to the top menu and select Terminal → New Terminal. -
Verify
ansible-navigatorinstallation. At the terminal prompt, run the following command to quickly test thatansible-navigatoris installed and view its options:ansible-navigator --help -
Create a test playbook. Now that you know
ansible-navigatoris installed, create a simple playbook file namedtest.ymlin 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.
-
Run the playbook with
ansible-navigator. Now, execute the playbook usingansible-navigatorin standard output mode (-m stdout), which mimics the output style ofansible-playbook:ansible-navigator run ./test.yml -m stdoutYou 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.