My Personal Notes on Vagrant

Home

1 Overview

In looking to run NXOSV, I noticed that Cisco offered the image for download in ESXi vmdk, ESXi ova, box (for Vagrant), and KVM (qcow2) formats. The box format uses Virtual Box along with Vagrant, both free GNU s/w. qcow2 the linux kernel virtual machine format is of course also free.

2 Virtual Box

Download from virtualbox.org written by Oracle (GNU license) I downloaded the 64 bit version.

3 Vagrant

Download from vagrantup.com This is NOT a gui app, but a CLI app that is installed in /opt/vagrant

which vagrant
/usr/local/bin/vagrant

common commands:

  • vagrant -version
  • vagrant -help
  • vagrant up

plenty more, just need to know which commands are needed for virtual box

vagrant -h <any-vagrant-command> to get a help page on that command.

for example:

  • vagrant -h up
  • vagrant -h destroy

4 socat

This is a serial console needed to access the virtual box VM, in our case NXOS I had this installed in /usr/local/bin/socat

To upgrade it I can use: brew upgrade socat (before doing that I performed some brew maintenance: see ~/eg/brew.org for instructions, but basically I did a brewup, followed by brew upgrade socat

socat 1.7.3.3 was already installed, so not upgraded

4.1 More on socat:

From http://macappstore.org/socat/,

To install the app,

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

  • brew install socat

Done! You can now use socat.

5 NXOSV

Can download version 7.0.3.I6.1 or 9.2.3 I downloaded both. Trying 9.2.3 first.

6 Installation

After Vagrant, Virtualbox, and NXOSv are downloaded follow these installation steps

  1. Confirm that vagrant is in your path: with which vagrant
  2. Confirm that Virtual Box is upgraded
  3. Move to the directory where you have the n9kv image, in my case it was ~/n9kv and the file is ~/n9kv/nxosv.9.2.3.box
  4. vagrant init from that directory
    A `Vagrantfile` has been placed in this directory. You are now
    ready to `vagrant up` your first virtual environment! Please read
    the comments in the Vagrantfile as well as documentation on
    `vagrantup.com` for more information on using Vagrant.
    
  5. vagrant box add base nxosv.9.2.3.box
    
    ==> box: Box file was not detected as metadata. Adding it directly...
    ==> box: Adding box 'base' (v0) for provider: 
        box: Unpacking necessary files from: file:///Users/zintis/n9kv/nxosv.9.2.3.box
    ==> box: Successfully added box 'base' (v0) for 'virtualbox'!
    
    
  6. Bring up the virtual machine with vagrant up
    
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Importing base box 'base'...
    ==> default: Matching MAC address for NAT networking...
    ==> default: Setting the name of the VM: n9kv_default_1560227516934_33652
    Vagrant is currently configured to create VirtualBox synced folders with
    the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
    guest is not trusted, you may want to disable this option. For more
    information on this option, please refer to the VirtualBox manual:
    
    https://www.virtualbox.org/manual/ch04.html#sharedfolders
    
    This option can be disabled globally with an environment variable:
    
    VAGRANT_DISABLE_VBOXSYMLINKCREATE=1
    
    or on a per folder basis within the Vagrantfile:
    
    config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false
    ==> default: Clearing any previously set network interfaces...
    ==> default: Preparing network interfaces based on configuration...
        default: Adapter 1: nat
    ==> default: Forwarding ports...
        default: 22 (guest) => 2222 (host) (adapter 1)
    ==> default: Booting VM...
    
    There was an error while executing `VBoxManage`, a CLI used by Vagrant
    for controlling VirtualBox. The command and stderr is shown below.
    
    Command: ["startvm", "98cc5376-f50f-43d7-a8ab-c8a44abeb33e", "--type", "headless"]
    
    Stderr: VBoxManage: error: The virtual machine 'n9kv_default_1560227516934_33652' has terminated unexpectedly during startup with exit code 1 (0x1)
    VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine
    
    
    

    While troubleshooting this error, I used the Virtual Box Manager gui to set the VM network interface to "promiscous" / "allow all" as per instructions in the guide

    I then shut down extra apps to free up memory and tried again.

    
    /Users/zintis/n9kv[20] % vagrant up
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Clearing any previously set network interfaces...
    ==> default: Preparing network interfaces based on configuration...
        default: Adapter 1: nat
    ==> default: Forwarding ports...
        default: 22 (guest) => 2222 (host) (adapter 1)
    
    There was an error while executing `VBoxManage`, a CLI used by Vagrant
    for controlling VirtualBox. The command and stderr is shown below.
    
    Command: ["modifyvm", "98cc5376-f50f-43d7-a8ab-c8a44abeb33e", "--natpf1", "ssh,tcp,127.0.0.1,2222,,22"]
    
    Stderr: VBoxManage: error: A NAT rule of this name already exists
    VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component NATEngineWrap, interface INATEngine, callee nsISupports
    VBoxManage: error: Context: "AddRedirect(Bstr(strName).raw(), proto, Bstr(strHostIp).raw(), RTStrToUInt16(strHostPort), Bstr(strGuestIp).raw(), RTStrToUInt16(strGuestPort))" at line 1869 of file VBoxManageModifyVM.cpp
    
    /Users/zintis/n9kv[21] % 
    
    

6.1 Home