Netdevops Developer Environments with Vagrant Do It Like They Do on the Developer Channel! Stuart Clark Netdevops Evangelist DEVNET-1365

Netdevops Developer Environments with Vagrant Do It Like They Do on the Developer Channel! Stuart Clark Netdevops Evangelist DEVNET-1365

#CLUS NetDevOps Developer Environments with Vagrant Do it like they do on the Developer Channel! Stuart Clark NetDevOps Evangelist DEVNET-1365 #CLUS Agenda • Vagrant 101 • Our first network vagrant up! • Vagrant + Ansible Provisioning • Multi-Node Topologies • The right tool for the right job… • How to do it yourself! DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 3 Cisco Webex Teams Questions? Use Cisco Webex Teams (formerly Cisco Spark) to chat with the speaker after the session How 1 Find this session in the Cisco Events App 2 Click “Join the Discussion” 3 Install Webex Teams or go directly to the team space 4 Enter messages/questions in the team space Webex Teams will be moderated cs.co/ciscolivebot#DEVNET-1365 by the speaker until June 18, 2018. #CLUS © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 44 Preparation Steps to Follow Along (or after) Workstation Requirements • Python Windows Workstation Caveats • 2.7.10 or higher • Vagrant & VirtualBox work great • 3.6.2 or higher • Ansible not supported on Windows (control station) • pip & virtual environment • Python scripts to create Vagrant boxes • ”git” command line tools require Linux or OS X • Vagrant • VirtualBox • Homebrew (Apple OS X) #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 6 Setup your Workstation • Clone the Repository • Setup Python Virtual Environment • Get Vagrant Box # From your “code” directory $ https://github.com/CiscoDevNet/learning_lab_vagrant_netprog_code $ cd learning_lab_vagrant_netprog_code $ ls –l README.md lab01 lab02 lab03 $ virtualenv venv --python=python3.6 $ source venv/bin/activate $ pip install –r lab03/requirements.txt #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 7 Vagrant 101 Development Environments Made Easy • Open Source Develop Tooling by lab\ $ vagrant init nxos/7.0.3.I7.3 lab\ $ vagrant up HashiCorp Bringing machine 'default' up with 'virtualbox' www.vagrantup.com provider... ==> default: Importing box ‘nxos/7.0.3.I7.3'... ==> default: Forwarding ports... • Simple configuration file stored default: 830 (guest) => 2223 (host) with code default: 80 (guest) => 2224 (host) default: 443 (guest) => 2225 (host) • “easy to configure, reproducible, default: 22 (guest) => 2222 (host) and portable work environments” lab\ $ vagrant ssh Nexus9000v# • Multi-Platform for both guest and host #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 9 Key Terms and Concepts • Vagrantfile (venv) lab\ $ ls lab02/ Vagrantfile • Configuration file for vagrant (venv) lab\ $ vagrant box list • centos/7 (virtualbox, 1611.01) Box iosxe/16.06.02 (virtualbox, 0) • Base images for different iosxr/6.1.2 (virtualbox, 0) nxos/7.0.3.I7.3 (virtualbox, 0) individual environments ubuntu/trusty64 (virtualbox, 20160323.0.0) • Provider (venv) lab\ $ vagrant box add nxos/7.0.3.I7.3 n9000v.box • Virtualization technology (venv) lab\ $ vagrant global-status used by vagrant id name provider state directory ------------------------------------------------------- • Default is VirtualBox, many 8d1eaec default virtualbox saved ~/coding/BRKDEV-1368 other supported #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 10 Vagrant Commands • vagrant init box name • vagrant provision • Initialize a new Vagrantfile in a • Re-run configured provisioner (eg Ansible) directory • vagrant box list • vagrant up / halt / destroy • Display list of available boxes • Start, stop, and delete an environment • vagrant status / global-status • Display current status of environments • Vagrant suspend / resume lab\ $ vagrant suspend • Pause and restart an environment ==> default: Saving VM state and suspending • vagrant ssh [machine] lab\ $ vagrant resume ==> default: Resuming suspended VM... • Connect via SSH to a running environment lab\ $ vagrant port 830 (guest) => 2223 (host) • vagrant port 22 (guest) => 2222 (host) • View the nat’d ports for the lab\ $ vagrant ssh environment Nexus9000v# #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 11 Explore Vagrant with Basic Linux VMs • Create new project directory lab\ $ mkdir vagrant_explore lab\ $ cd vagrant_explore • Initialize a new Vagrant environment vagrant_explore\ $ vagrant init hashicorp/precise64 • Bring it up vagrant_explore\ $ vagrant up #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 12 Explore Vagrant with Basic Linux VMs • Connect to your environment vagrant_explore\ $ vagrant ssh with SSH # Now you’re inside the Vagrant VM • vagrant@precise64:~$ Explore lifecycle operations of vagrant@precise64:~$ pwd Vagrant vagrant@precise64:~$ exit # Back on your local workstation vagrant_explore\ $ vagrant status vagrant_explore\ $ vagrant suspend vagrant_explore\ $ vagrant resume vagrant_explore\ $ vagrant reload vagrant_explore\ $ vagrant destroy #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 13 Vagrantfile Basics # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant is a Ruby application # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for Majority of default # backwards compatibility). Please don't change it unless you know what Vagrantfile is comments # you're doing. Vagrant.configure("2") do |config| Start Configuration Block # Every Vagrant development environment requires a box. # You can search for boxes at https://vagrantcloud.com/search. config.vm.box = "hashicorp/precise64" Identify the box to use end End Configuration Block Note: Vagrant Boxes can include default settings* Partial* fileSimplified output displayed and editedfor presentation sample #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 14 Our first network vagrant up! Initialize your Vagrantfile lab\ $ cd lab01/ • View available boxes hands_on_1\ $ vagrant box list • Initialize new Vagrant File hands_on_1\ $ vagrant box add nxos/7.0.3.I7.3 ~/Downloads/nxosv-final.7.0.3.I7.3.box –force hands_on_1\ $ vagrant init nxos/7.0.3.I7.3 hands_on_1\ $ open Vagrantfile #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 16 Vagrantfile Basics (for Network Devices) # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # Every Vagrant development environment requires a box. You can search for Box Name # boxes at https://atlas.hashicorp.com/search. config.vm.box = ”nxos/7.0.3.I7.3" config.ssh.insert_key = false Don’t insert Vagrant public key. Recommended # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. config.vm.network "forwarded_port", guest: 830, host: 2223, id: "netconf" Forward local ports for config.vm.network "forwarded_port", guest: 80, host: 2224, id: ”http" API/App access. config.vm.network "forwarded_port", guest: 443, host: 2225, id: "restconf-ssl" SSH is forwarded by default # Create a private network, which allows host-only access to the machine # using a specific IP. config.vm.network :private_network, virtualbox__intnet: "link1", auto_config: false Create environment config.vm.network :private_network, virtualbox__intnet: "link2", auto_config: false networks. end ”eth1” connected to host by default Note: Vagrant Boxes can include default settings * Simplified and edited sample #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 17 Let’s add more interfaces and open up API Access • Open Vagrantfile • Add port forwarding • Add 2 Interfaces to Configuration • Specific positioning in file is irrelevant * Simplified and edited sample • * Must be within |config| block Vagrant.configure("2") do |config| config.vm.box = "nxos/7.0.3.I7.3" # Forward API Port config.vm.network :forwarded_port, guest: 80, host: 2224, id: 'http' # Create a private networks config.vm.network :private_network, virtualbox__intnet: "link1", auto_config: false config.vm.network :private_network, virtualbox__intnet: "link2", auto_config: false end or cp Vagrantfile.solution Vagrantfile #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 18 Start a Vagrant Environment lab01\ $ vagrant up • Start environment # Known ssh bug • View NAT’d ports for APIs # vagrant up 2nd time lab01\ $ vagrant up • Connect to running switch lab01\ $ vagrant port lab01\ $ vagrant ssh Note: Due to the nature of the Nexus 9000v shell, vagrant will report an error after starting the VM. This is expected, and does not indicate a problem. Simply enter vagrant up again to complete the setup successfully. #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 19 Explore the Vagrant Environment # Run from Vagrant Environment (ie vagrant ssh) • Baseline Configurations n9kv1# sh run | inc "username vagrant" • Logins – User / Cert Nexus9000v# sh run int mgmt0 • APIs Nexus9000v# sh run | inc feature • Interfaces Nexus900v# conf t • Open NX-API Developer Nexus9000v(config)# feature nxapi Sandbox # Exit from Vagrant Environment http://127.0.0.1:2224 • Make an API Call #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 20 Destroy Hands on Demo 1 lab01\ $ vagrant destroy • Destroy this environment #CLUS DEVNET-1365 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 21 Vagrant + Ansible Provisioning Come on..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    49 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us