Exercise 1 - Exploring the lab environment

Read this in other languages: uk English, japan 日本語, Español Español.

Table of Contents


Explore and understand the lab environment.

These first few lab exercises will be exploring the command-line utilities of the Ansible Automation Platform. This includes

If you need more information on new Ansible Automation Platform components bookmark this landing page https://red.ht/AAP-20

Join our community forum!

Before you get started, please join us on https://forum.ansible.com/. This will allow you to get Ansible help after the workshops concludes.


Red Hat Ansible Automation


Step 1 - Connecting via VS Code

It is highly encouraged to use Visual Studio Code to complete the workshop exercises. Visual Studio Code provides:
  • A file browser
  • A text editor with syntax highlighting
  • A in-browser terminal
Direct SSH access is available as a backup, or if Visual Studio Code is not sufficient to the student. There is a short YouTube video provided if you need additional clarity: Ansible Workshops - Accessing your workbench environment.

Step 2 - Using the Terminal

Navigate to the network-workshop directory on the Ansible control node terminal.

[student@ansible-1 ~]$ cd ~/network-workshop/
[student@ansible-1 network-workshop]$ pwd
[student@ansible-1 network-workshop]$

Step 3 - Examining Execution Environments

Run the ansible-navigator command with the images argument to look at execution environments configured on the control node:

$ ansible-navigator images

ansible-navigator images


The output you see might differ from the above output

This command gives you information about all currently installed Execution Environments or EEs for short. Investigate an EE by pressing the corresponding number. For example pressing 0 with the above example will open the network-ee execution environment:

ee main menu

Selecting 2 for Ansible version and collections will show us all Ansible Collections installed on that particular EE, and the version of ansible-core:

ee info

Step 4 - Examining the ansible-navigator configuration

Either use Visual Studio Code to open or use the cat command to view the contents of the ansible-navigator.yml file. The file is located in the home directory:

$ cat .ansible-navigator.yml 
      - /home/student/lab_inventory/hosts

    image: quay.io/acme_corp/network-ee:latest
    enabled: true
    container-engine: podman
      policy: missing
    - src: "/etc/ansible/"
      dest: "/etc/ansible/"

Note the following parameters within the ansible-navigator.yml file:

For a full listing of every configurable knob checkout the documentation

Step 5 - Examining inventory

The scope of a play within a playbook is limited to the groups of hosts declared within an Ansible inventory. Ansible supports multiple inventory types. An inventory could be a simple flat file with a collection of hosts defined within it or it could be a dynamic script (potentially querying a CMDB backend) that generates a list of devices to run the playbook against.

In this lab you will work with a file based inventory written in the ini format. Either use Visual Studio Code to open or use the cat command to view the contents of the ~/lab_inventory/hosts file.

$ cat ~/lab_inventory/hosts


rtr1 ansible_host= private_ip=
rtr2 ansible_host= private_ip=
rtr4 ansible_host= private_ip=
rtr3 ansible_host= private_ip=






ansible ansible_host= ansible_user=student private_ip=

Step 6 - Understanding inventory

In the above output every [ ] defines a group. For example [dc1] is a group that contains the hosts rtr1 and rtr3. Groups can also be nested. The group [routers] is a parent group to the group [cisco]

Parent groups are declared using the children directive. Having nested groups allows the flexibility of assigining more specific values to variables.

We can associate variables to groups and hosts.


A group called all always exists and contains all groups and hosts defined within an inventory.

Host variables can be defined on the same line as the host themselves. For example for the host rtr1:

rtr1 ansible_host= private_ip=

Group variables groups are declared using the vars directive. Having groups allows the flexibility of assigning common variables to multiple hosts. Multiple group variables can be defined under the [group_name:vars] section. For example look at the group cisco:


Step 7 - Using ansible-navigator to explore inventory

We can also use the ansible-navigator TUI to explore inventory.

Run the ansible-navigator inventory command to bring up inventory in the TUI:

ansible-navigator tui

Pressing 0 or 1 on your keyboard will open groups or hosts respectively.

ansible-navigator groups

Press the Esc key to go up a level, or you can zoom in to an individual host:

ansible-navigator host

Step 8 - Connecting to network devices

There are four routers, named rtr1, rtr2, rtr3 and rtr4. The network diagram is always available on the network automation workshop table of contents. The SSH configuration file (~/.ssh/config) is already setup on the control node. This means you can SSH to any router from the control node without a login:

For example to connect to rtr1 from the Ansible control node, type:

$ ssh rtr1

For example:

$ ssh rtr1
Warning: Permanently added 'rtr1,' (RSA) to the list of known hosts.

rtr1#show ver
Cisco IOS XE Software, Version 16.09.02


The workshops have just been upgraded to Red Hat Enterprise Linux 9 which is using a newer more secure system-wide cryptographic policy. If you hit the issue no mutual signature supported for a Cisco network device, please run the command sudo update-crypto-policies --set LEGACY and exit/restart your terminal so the policy will take effect. This will be fixed in a future workshop release. Please open issues on https://github.com/ansible/workshops


You have completed lab exercise 1!

You now understand:

Next Exercise

Click Here to return to the Ansible Network Automation Workshop