online posts 16
ansible 101 for networking

task 1.1 · chapter 1 of 8: hello, ansible · 15 min

Meet the lab

objective

Open the lab, find your way around it, and prove all three switches answer.

given
Switchesspine1, leaf1, leaf2 (CapeOS Bolt)
Loginadmin / capeos-lab
Lab folder/workspaces/ansible-101: everything you edit is in here

First lab here? Meet the lab shows how every lab works: the lab app, the editor, make and the checker. This task covers only what’s specific to this lab.

1 explain

What’s in the Ansible 101 lab?

The lab is a small data center network that runs inside a container in your browser: three switches, wired as a leaf-spine fabric, plus a Linux host on each leaf.

            spine1
       Gi1 /      \ Gi2
      Gi1 /        \ Gi1
      leaf1        leaf2
       Gi2|          |Gi2
      host1        host2

spine1 is in the middle; leaf1 and leaf2 are where servers plug in. The switches run CapeOS Bolt, a network operating system built for labs. Its command line is the classic one: show running-config, configure terminal, interface GigabitEthernet1, write memory. If you’ve configured a switch before, you already know how to look at these.

Around them is the lab app: this guide on the left and VS Code, a code editor, in the tab on the right. You’ll use three parts of VS Code all the way through the lab:

  • the Explorer on the left: the lab’s files and folders;
  • the editor in the middle: where you open and change files;
  • the terminal at the bottom: where you type commands like make check.
2 show

Where are the lab’s files?

Everything lives in one folder, /workspaces/ansible-101. The parts you’ll touch:

ansible-101/
├── ansible.cfg          how Ansible behaves in this folder (you'll read it, not change it)
├── inventory/           which switches exist, and facts about them        chapters 1, 3, 4
├── playbooks/           the automation you write                          chapters 2 to 5
├── answers/             answers to the questions in chapter 1
├── roles/               reusable pieces, from chapter 6
├── checks/              the checker behind make check (no need to open it)
└── Makefile             the shortcuts: make run, make check, make ssh ...

Every task page lists the files you’ll edit near the top, under you edit, in the lab. To open one, press Ctrl+P (Cmd+P on a Mac), type its name, and press Enter.

3 follow along

Open the lab and look around

  1. Click Open the lab and sign in with GitHub (a free account is fine). It makes your own copy of the lab and opens the lab app.

  2. Wait about 6 minutes the first time, until the top bar says network up: the three switches and two hosts are running.

  3. In the VS Code tab, VS Code may ask whether you trust the authors of the folder. Click Trust Folder & Continue.

  4. Open a terminal of your own: menu Terminal → New Terminal, or Ctrl+`. Check Ansible is there:

    run in the terminal
    ansible --version
    

    Look at the config file = line. It should end in ansible-101/ansible.cfg: Ansible found the lab’s settings. (If it says None, see part 1.)

  5. Log in to a switch. Open the Topology tab and click leaf1. A tab named leaf1 opens with the switch’s command line.

    At the leaf1# prompt, type show version and press Enter, then show running-config. A factory switch: a hostname, three ports, all of them shutdown except the management port.

4 challenge

Find the cable

On your own: which port on spine1 is leaf2 plugged into? Find out from the switches, not from the diagram.

hint

Switches tell each other who they are with a protocol called LLDP. On a factory switch it’s off, and the ports are shut down, so the switches can’t tell you yet. The topology file can: lab/fabric.clab.yml, at the bottom.

hint

The topology names ports the way Linux does, eth1. The switch calls the same port GigabitEthernet1.

show the solution

lab/fabric.clab.yml lists the cables:

  links:
    - endpoints: ["spine1:eth1", "leaf1:eth1"]
    - endpoints: ["spine1:eth2", "leaf2:eth1"]

So leaf2 is on spine1’s GigabitEthernet2, and on leaf2’s side it’s GigabitEthernet1. In chapter 2 you’ll turn on LLDP, and in chapter 4 bring the ports up; after that show lldp neighbors on spine1 tells you the same thing from the switch itself.

5 check: run it, then prove it

$ make status
$ make check T=1.1

when it's right, you'll see

╭─ task 1.1 · meet the lab
│  ✓ ansible-core 2.20.1 is installed
│  ✓ the cisco.ios collection is installed (11.6.0)
│  ✓ spine1 answers (CapeOS Bolt 0.1.2)
│  ✓ leaf1 answers (CapeOS Bolt 0.1.2)
│  ✓ leaf2 answers (CapeOS Bolt 0.1.2)
╰─ 5/5 checks passed  verified