Overview
Network as Code
  • Introduction
  • Nexus One Fabric
  • System Access
  • Site1 Fabric (Greenfield)
  • Validate Site1 Fabric
  • External L3
  • Validate ExtL3
  • Site2 Fabric (Brownfield)
  • Validate Site2 Fabric
  • Inter-Site Network
  • Unified Management
  • Fabric Groups
  • Validate MultiClstr Fabric
  • Network as Code

Network As Code (https://netascode.cisco.com/) aims to reduce time to value by lowering the barrier of entry to network orchestration through simplification, abstraction, and curated examples.

It allows users to instantiate network in minutes using an easy to use, opinionated data model and takes away the complexity of having to deal with references, dependencies or loops. Users can focus on describing the intended configuration while using a set of maintained and tested Ansible Modules without the need to understand the low-level network device configuration.

Network as Code has several Data Models to help customer leverage the same methodology for their entire network. Some of these models include:

  • Catalyst Center
  • Meraki
  • VXLAN
  • ISE
  • ACI
  • SDWAN
  • FMC

In this particular section of the lab, we will be leveraging the VXLAN module to configure and deploy and new VRF.

The VXLAN Data Model structure is divided into multiple high level sections:

  • fabric: Used to configure fabric name and fabric type
  • multisite: Multisite (MSD) and child fabric configuration
  • global: Fabric wide configuration, such as underlay protocol
  • topology: Switch specific configuration and intra-fabric/inter-fabric links
  • underlay: Underlay protocol configuration
  • overlay: Layer2 and Layer3 overlay service configuration
  • overlay_extensions: VRF-Lite and route control configuration
  • policy: Policy configuration

It is important to continue to check the Network as Code website as new features continue to be added to the Data Models.

Step 1 - Microsoft Visual Studio Code

To make things easier in the lab, we have created an environment leveraging the web version of Microsoft Visual Studio Code. This tool will allow us to create and edit the necessary files needed to get Service as Code working.

To access your POD which contains your Microsoft Visual Studio Code instance, please go to:

https://10.0.226.241:16005/?folder=vscode-remote://10.0.226.241:16005/home/pod05/ltrdcn-2654

  • Password: ciscolivelabs

After succesfully logging to Microsoft Visual Studio Code, you will be presented with the following screen:

Step 2 - Open a Terminal

Please open terminal session inside Microsoft Visual Studio Code by following steps:

  1. Click the Three Lines in the left navigation bar
  2. Click Terminal
  3. Click New Terminal

At the bottom of the screen the terminal will appear with the following prompt:

pod5 ~/ltrdcn-2654 $:

Please contact one of the lab instructor if the prompt is different.

Step 3 - Setup the Environment

Before we start taking advantage of Service as Code and the VXLAN Data Model, we need to setup our working environment. This requires setting up:

  • A Python Environment
  • Create a Virtual Environment
  • Setup Ansible
  • Install VXLAN Data Model Collection

NOTE: During the following steps you can leverage the copy function as well by hovering your mouse just below the Cisco logo and the copy icon will display. Allowing you to copy the command and then, being able to paste the command in the terminal. As in previous section we are trying to minimize errors.


pyenv install 3.10.13


pyenv versions

* system (set by /home/pod05/.pyenv/version)
  3.10.13

Step 4 - Configure global version of Python


pyenv global 3.10.13


Step 5 - Create virtual environment with PyENV

The command to create your virtual environment using pyenv is pyenv virtualenv {python_version} {virtualenv_name}. Create a virtual environment called nac-ltrdcn-2654 using the 3.10.13 Python version you previously installed. Do this by either typing or copying the command below into your VSCode Terminal window:


pyenv virtualenv 3.10.13 nac-ltrdcn-2654


Step 6 - Set VirtualEnv in Project Directory

Next, use the pyenv local {virtualenv_name} to set the virtualenv for the project. This will create a .python-version file within the current directory, thus the reason we went ahead and changed directory into the project directory. This file is powerful as it will handle activating and deactiving the virtualenv as you move in and out of the project directory automatically, otherwise, this is an action you would need to perform manually or by some other automated means. Do this by either typing or copying the command below into your VSCode Terminal window:


pyenv local nac-ltrdcn-2654

And with that you have created and activated the virtual environment you will use during this lab. Notice that it placed you inside the virtual environment after creating it. The important part is the way the SHELL looks like while you are inside the virtual environment. Notice the (nac-ltrdcn-2654) at the start of the line; that indicates the virtualenv is active.

What active virtualenv looks like:

(nac-ltrdcn-2654) pod05 ~/../nac-ltrdcn-2654 $:


Now, that we have setup our environment, let's move to the next session to setup Service as Code for our VXLAN environment.