Learn / Stage 3: Networking and CCNA / Lesson 3.14

$ lesson 3.14 --track ccna --domain automation

Network Automation and Programmability: Controllers, REST, JSON, Ansible and AI

The last CCNA topic is the one that changes how you will do all the others. Learn how controllers and APIs replace box by box configuration, read the JSON they return, see where Ansible, Terraform and AI fit, and how to stop automation from becoming the fastest way to break a network.

  • Stage 3 Networking and CCNA
  • Level Advanced
  • 60 min
  • 5 sections, quiz, lab

Start the lesson Jump to the lab

By the end of this lesson you can

  • Explain why automation helps and name the three planes
  • Describe controller based networking and SDN layers and APIs
  • Match CRUD to HTTP verbs and read common status codes and auth types
  • Read and fix JSON and extract values by path
  • Explain what Ansible, Terraform and AI do in network operations, and their risks
3.14.01

Why automate, and the three planes

Typing the same NTP server into 300 devices by hand takes a day and produces a few typos. A script or tool does it in minutes, identically, and can report every device whose config has drifted from the standard. Automation does not replace network engineers; it removes repetitive work so they can design, review and troubleshoot.

Three planes inside a network device: management on top, control in the middle, data at the bottomManagement planeSSH, SNMP, APIs: how people and tools configure and monitorControl planeOSPF, STP, ARP: building the tablesData planeforwarding each packet using those tables
Separating the planes is what makes controllers possible: the management and some control decisions can move off the box.

Controller based networking centralises management (and sometimes control) logic. Examples: Cisco Catalyst Center (formerly DNA Center) for campus, SD-WAN Manager for WAN, and APIC for ACI data centres. Instead of logging into each switch, you describe what you want once and the controller pushes it.

3.14.02

SDN: underlay, overlay, fabric and APIs

SDN: applications use the controller's northbound API; the controller talks to devices through southbound interfacesApps, scripts, dashboardsControllerfor example Catalyst CenterNetwork devicesnorthbound API (usually REST)southbound: NETCONF, RESTCONF, SSH, SNMP, OpenFlow
Northbound is where your code talks to the controller. Southbound is how the controller talks to devices.
  • Underlay: the physical IP network: links, routing, addresses.
  • Overlay: virtual networks built as tunnels on top of the underlay, for example VXLAN.
  • Fabric: underlay and overlay managed together as one system.

Virtualisation runs on the same idea of abstraction. A type 1 hypervisor runs on bare metal (VMware ESXi, Microsoft Hyper-V, KVM); a type 2 runs on top of an operating system (VirtualBox, VMware Workstation). Virtual machines each carry a full operating system; containers share the host's kernel and are lighter. In networking, a VRF gives one router several separate routing tables, so different customers or departments can even reuse the same addresses.

3.14.03

REST APIs

REST is an architectural style, usually over HTTP: client and server, stateless (every request carries everything needed, including authentication), with resources identified by URLs.

CRUD and HTTP verbs
CRUDHTTP verbExample
CreatePOSTAdd a device to the inventory
ReadGETList devices
UpdatePUT (replace) or PATCH (change part)Change a device's location
DeleteDELETERemove a device
HTTP status codes
CodeMeaning
200 OKSuccess, here is the result
201 CreatedA new resource was made
204 No ContentSuccess, nothing to return
400 Bad RequestYour request is malformed
401 UnauthorizedNot authenticated (missing or bad credentials or token)
403 ForbiddenAuthenticated, but not allowed
404 Not FoundNo such resource
500 Internal Server ErrorThe server failed

Authentication types: HTTP Basic (username and password Base64 encoded, which is encoding not encryption, so HTTPS only), API keys, bearer tokens (often obtained by first POSTing credentials, then sent in a header on each request), and OAuth for delegated access.

A typical token flow

Use Next or the arrow keys. Paths are examples in the style of Cisco's APIC-EM API.

    1. Ask for a token

    POST /api/v1/ticket with a JSON body containing username and password, over HTTPS.

    2. Receive it

    The reply is 200 with JSON holding a ticket (token). A wrong password gets a 401 style error.

    3. Use it

    GET /api/v1/network-device with the token in a header such as X-Auth-Token. No password travels again.

    4. Read the JSON

    Parse the reply and pick out what you need, for example each device's hostname, as in the reader below.

    3.14.04

    Reading JSON

    JSON is the most common encoding for API data (XML and YAML are the others you will meet). Its types: an object { } of key value pairs, an array [ ] of values, a string in double quotes, a number, true or false, and null. Keys must be strings in double quotes. Standard JSON allows no comments, no single quotes and no trailing commas.

    JSON reader: an inventory reply

    Edit the JSON and check it, or load a broken example and find the mistake. Then type a path such as response[0].hostname to pull out one value.

      The JSON above is illustrative, written for this lesson. A real controller's field names may differ, so read what yours returns.

      3.14.05

      Ansible, Terraform and AI

      Ansible compared with Terraform
      AnsibleTerraform
      StyleProcedural tasks in order, aiming to be idempotent (safe to run twice)Declarative: describe the end state
      LanguageYAML playbooksHCL
      How it reaches devicesAgentless, over SSH or APIs, using modulesProviders that talk to platform APIs
      Dry runansible-playbook --checkterraform plan, then apply
      RemembersAn inventory of hostsA state file of what it created
      - name: Set NTP on all routers
        hosts: routers
        gather_facts: false
        tasks:
          - name: Push the NTP server
            cisco.ios.ios_config:
              lines:
                - ntp server 192.168.1.100

      This uses the ios_config module from the cisco.ios collection; the inventory would put your routers in a routers group with ansible_network_os: cisco.ios.ios and ansible_connection: network_cli. Terraform has providers for Cisco platforms (for example IOS XE); the resource names depend on the provider version, so check its documentation before writing one.

      AI and machine learning in network operations: predictive and ML tools learn a baseline of normal behaviour, flag anomalies and forecast capacity; generative AI drafts configs, summarises logs and answers questions in plain language. It can also be confidently wrong, so everything it produces is reviewed and lab tested like a junior engineer's change.

      Flashcards: do you remember?

      Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.

      Quick quiz

      Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.

      Q1Which HTTP verb reads data?

      Q2A script gets 401 from the controller. Most likely:

      Q3Which is valid JSON?

      Q4Which interface does a controller use to configure devices?

      Q5What makes Ansible different from many tools?

      Q6Generative AI wrote a config for you. What next?

      0 / 6

      Hands-on lab

      Cisco Packet Tracer lab50 minutessimulated network

      Packet Tracer lab 3.14: talk to the Packet Tracer Network Controller with REST

      You need: Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Packet Tracer 8.2 and later include a Network Controller device that, per Cisco's PT FAQ, offers a web GUI and APIs reachable from a browser, Python or Postman. That FAQ page could not be opened directly when this was written (it was read from a search result), so treat the details as UNVERIFIED. Devices: Network Controller, 2 x ISR4331, 1 x 2960, 1 x PC-PT.

      Topology and addressing

      Lab 3.14 topology: a Packet Tracer Network Controller, Admin-PC, SW1 and R1 on 192.168.1.0/24, and R2 behind R1 on 10.0.12.0/30Gi0/0/0Gi0/0/1 .1Network Controller192.168.1.200SW1192.168.1.2Admin-PC192.168.1.50R1Gi0/0/0 .1R2Gi0/0/1 10.0.12.2
      Controller, Admin-PC and R1 Gi0/0/0 on SW1. R1 Gi0/0/1 to R2 Gi0/0/1 (10.0.12.0/30).
      Addressing table
      DeviceInterfaceIPv4 address / prefixDefault gateway or note
      ControllerGi0192.168.1.200/24gateway 192.168.1.1
      R1Gi0/0/0 / Gi0/0/1192.168.1.1/24 / 10.0.12.1/30
      R2Gi0/0/110.0.12.2/30static route to 192.168.1.0/24 via 10.0.12.1
      SW1VLAN 1192.168.1.2/24gateway .1
      Admin-PCFa0192.168.1.50/24gateway .1
      1. Prepare the devices

        R1(config)#hostname R1
        R1(config)#ip domain-name cwm.lab
        R1(config)#username admin secret <a long password>
        R1(config)#crypto key generate rsa modulus 2048
        R1(config)#line vty 0 4
        R1(config-line)#login local
        R1(config-line)#transport input ssh
        R2(config)#ip route 192.168.1.0 255.255.255.0 10.0.12.1

        Repeat the SSH setup on R2 and SW1.

      2. Controller GUI

        From Admin-PC's browser open http://192.168.1.200 (or https, depending on the build), create the admin account, and add R1, R2 and SW1 with their SSH credentials. The section is called something like Provisioning or Discovery; names vary by build and are UNVERIFIED.

      3. Compare views

        Read the controller's inventory and topology views and compare them with show cdp neighbors on R1.

      4. REST from Admin-PC

        Open Desktop, Programming (Packet Tracer's Python environment). The controller is commonly documented with APIC-EM style endpoints: POST /api/v1/ticket to get a token and GET /api/v1/network-device with an X-Auth-Token header. These paths, the header name and the Python modules available inside Packet Tracer are UNVERIFIED for your build: open the controller's own API documentation page and Packet Tracer's sample programs first, then write the script.

      5. Read the reply

        In the JSON you get back, find an object, an array, a string and a number, and write down the path to each device's hostname, as in the JSON reader in this lesson.

      6. Paper exercise

        Outside Packet Tracer: write a short Ansible playbook outline that sets the NTP server on all routers (like the one above), then describe the same intent as a Terraform outline. What would --check and terraform plan show you before anything changes?

      You are done when: The controller lists R1, R2 and SW1 as managed and reachable; your script prints a successful (200) reply for the token request and for the device list, and a wrong password gives an authentication error (a 401 style code; the exact code in Packet Tracer is UNVERIFIED).

      Packet Tracer limits and notes

      • Ansible, Terraform, NETCONF and RESTCONF do not run inside Packet Tracer. Practise them later on a Linux machine (Stage 2 of this path prepares you).
      • Packet Tracer's Programming environment supports a subset of Python with its own HTTP helper modules; exact module names are UNVERIFIED, so start from its sample programs.
      • Field names in a real controller reply may differ from the illustration in this lesson. The AI and machine learning topic has no Packet Tracer lab: as a discussion exercise, take a syslog excerpt and an AI generated root cause, and check whether the logs really support it.
      • Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.

      Download the lab checklist (.txt) Print it or keep it open beside Packet Tracer.

      Key takeaways

      • Automation brings speed, consistency and drift detection; engineers still design and review.
      • Data, control and management planes; controllers centralise the management side.
      • Northbound to the controller, southbound to devices.
      • REST: POST, GET, PUT or PATCH, DELETE, and know 200, 201, 204, 400, 401, 403, 404, 500.
      • JSON: double quotes, no comments, no trailing commas.
      • Protect tokens and secrets, dry run every change, and verify anything AI writes.

      Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.