Intro

Previously I created a vManage Vagrant box for use with the vagrant-libvirt provider. In this post I will show you how to install a Viptela vBond/vEdge appliance for use with the vagrant-libvirt provider.

Since the vBond and vEdge use the same software we can use the same base image to create either a vBond orchestrator or vEdge cloud VM.

For reference the following software will be used in this post.

  • Viptela vBond/vEdge - 16.3.2
  • Vagrant - Vagrant 2.0.1
  • vagrant-libvirt - 0.4.0
  • Ubuntu - 1604

Download

Viptela does not host any boxes on Vagrant cloud so we will need to build it ourselves. Go to https://docs.viptela.com/Downloads and dowload the 16.3.2 vBond/vEdge KVM image for new deployments.

blog/viptela-vbond-vedge-vagrant-libvirt-box-install/viptela-vbond-vedge-download.png
Note
You will either need be an existing customer/partner or speak to your Cisco/Viptela account manager to gain access to the Viptela support portal.

Install

Create and change into directory for vBond/vEdge files. I like to keep my custom vagrant boxes under ~/vagrant/boxes/ .

cmd
mkdir -p ~/vagrant/boxes/viptela
cd ~/vagrant/boxes/viptela

Copy the .qcow2 file downloaded earlier to the ~/vagrant/boxes/viptela directory.

cmd
cp ~/Downloads/viptela-16-3-2/viptela-edge-genericx86-64.qcow2 .

Use the below virt-install command to build the vBond/vEdge VM. Be sure to add at least two interfaces.

cmd
virt-install \
    --name vbond-vedge-base \
    --os-type linux \
    --os-variant ubuntu14.04 \
    --cpu host \
    --vcpus=2 \
    --hvm \
    --arch=x86_64 \
    --ram 1024 \
    --disk path=viptela-edge-genericx86-64.qcow2,size=16,device=disk,bus=ide,format=qcow2 \
    --network=network:vagrant-libvirt,model=virtio \
    --network=network:vagrant-libvirt,model=virtio \
    --graphics none \
    --import

A virtual console will be connected to the VM and you will see the below. It will take about a minute for the VM to boot, once it does login with the username: admin and password: admin .

cmd
Starting install...
Creating domain...                                                                                                                                                                          |    0 B  00:00:01
Connected to domain vbond-vedge-base
Escape character is ^]
viptela 16.3.2
vedge login:

Apply the following bootstrap configuration.

cmd
config
system
 aaa
  user vagrant
   password $6$yW1ez6tP1rqv15nA$2uA0TXEIuCuGnPa4bUVCSN4o5b.wU/WMzBa4kjYvBz4B/EbbJY3he9CMaY0UWPi0joUqUxYC.F6xbYHQQcq2o/
   group    netadmin
   !
  !
  commit and-quit

The bootstrap config will create the vagrant user with the password vagrant but we still need to load the vagrant ssh key.

Login to the vshell shell with the vshell command.

cmd
# viptela_cli

vedge# vshell

# Now in vshell

vedge:~$

Switch to the vagrant user.

cmd
su vagrant
password: <vagrant>

# log back into vshell

vedge# vshell

Create the .ssh directory.

cmd
mkdir /home/vagrant/.ssh && cd /home/vagrant/.ssh

Use vim to add the vagrant public key to the authorized_keys file.

cmd
/home/vagrant/.ssh/authorized_keys

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key

Exit back to the viptela_cli and use the show int | tab command to get the IP address assigned to the eth0 interface.

cmd
vshell

vedge:/home/vagrant/.ssh$ exit

viptela_cli

vedge# show int | tab

# output

                                          IF      IF                                                                TCP
                AF                        ADMIN   OPER    ENCAP                                      SPEED          MSS                 RX       TX
VPN  INTERFACE  TYPE  IP ADDRESS          STATUS  STATUS  TYPE   PORT TYPE  MTU   HWADDR             MBPS   DUPLEX  ADJUST  UPTIME      PACKETS  PACKETS
----------------------------------------------------------------------------------------------------------------------------------------------------------
0    ge0/0      ipv4  192.168.121.158/24  Up      Up      null   transport  1500  52:54:00:87:1e:d5  10000  full    1420    0:00:19:22  422      671
512  eth0       ipv4  192.168.121.200/24  Up      Up      null   service    1500  52:54:00:7d:71:33  0      half    0       0:00:19:21  1286     355

From another terminal, confirm that you can ssh to the vBond/vEdge with the Vagrant insecure_private_key .

cmd
ssh vagrant@192.168.121.200 -i ~/.vagrant.d/insecure_private_key

# Success

Welcome to Viptela CLI
vagrant connected from 192.168.121.1 using ssh on vedge
vedge#

If you successfully connected, poweroff the vBond/vEdge in preparation for the Vagrant box creation.

cmd
vedge# poweroff
Are you sure you want to power off the system? [yes,NO] yes

To exit the console use one of these key combinations (Assuming English keyboard).

  • CTRL + ]
  • CTRL + 5
  • Press and hold CTRL and SHIFT while pressing 6 then ]

Box Creation

The maintainers of the vagrant-libvirt plugin have a script that can be used to convert .qcow2 images to a vagrant box. Download the libvirt conversion script.

cmd
curl -O https://raw.githubusercontent.com/vagrant-libvirt/vagrant-libvirt/master/tools/create_box.sh

Create a metadata.json file.

file
echo '{"provider":"libvirt","format":"qcow2","virtual_size":16}' > metadata.json

Use the create_box.sh script to make a Vagrant box from the .qcow2 image.

cmd
bash create_box.sh viptela-edge-genericx86-64.qcow2

# output

{11}
==> Creating box, tarring and gzipping
./metadata.json
./Vagrantfile
./box.img
Total bytes written: 200089600 (191MiB, 40MiB/s)
==> viptela-edge-genericx86-64.box created
==> You can now add the box:
==>   'vagrant box add viptela-edge-genericx86-64.box --name viptela-edge-genericx86-64'

Create a metadata file called vbond-vedge.json so that the box is added with the correct version number.

file
{
  "name": "viptela/vbond-vedge",
  "description": "Viptela vBond/vEdge",
  "versions": [
    {
      "version": "16.3.2",
      "providers": [
        {
          "name": "libvirt",
          "url": "file:///home/bradmin/vagrant/boxes/viptela/viptela-edge-genericx86-64.box"
        }
      ]
    }
  ]
}

Add the box to Vagrant using the vbond-vedge.json file.

cmd
vagrant box add vbond-vedge.json

# output

==> box: Loading metadata for box 'vbond-vedge.json'
    box: URL: file:///home/bradmin/vagrant/boxes/viptela/vbond-vedge.json
==> box: Adding box 'viptela/vbond-vedge' (v16.3.2) for provider: libvirt
    box: Unpacking necessary files from: file:///home/bradmin/vagrant/boxes/viptela/viptela-edge-genericx86-64.box
==> box: Successfully added box 'viptela/vbond-vedge' (v16.3.2) for 'libvirt'!

Confirm the vBond/vEdge box was added successfully.

cmd
vagrant box list

# output

CumulusCommunity/cumulus-vx          (libvirt, 3.4.1)
.
. <snip>
.
viptela/vbond-vedge                  (libvirt, 16.3.2)

viptela/vmanage                      (libvirt, 16.3.2)
vyos/current                         (libvirt, 999.201712301253)

Vagrantfile

Use this Vagrantfile to test out the new vBond/vEdge Vagrant box.

file
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "viptela/vbond-vedge"

  # Turn off shared folders
  config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true

  # Do not try to insert new SSH key
  config.ssh.insert_key = false

  # Give VM time to boot
  config.vm.boot_timeout = 180

  # Provider-specific configuration
  config.vm.provider :libvirt do |domain|
    domain.memory = 1024
    domain.cpus = 2
  end

  # Additional Interfaces
  config.vm.network "private_network", ip: "169.254.1.11", auto_config: false
  config.vm.network "private_network", ip: "169.254.1.12", auto_config: false
  config.vm.network "private_network", ip: "169.254.1.12", auto_config: false
end

Testing

Lets vagrant up and make sure we can connect to the vBond/vEdge.

cmd
vagrant up

# output

Bringing machine 'default' up with 'libvirt' provider...
==> default: Uploading base box image as volume into libvirt storage...
==> default: Creating image (snapshot of base box volume).
==> default: Creating domain with the following settings...
==> default:  -- Name:              viptela_default
==> default:  -- Domain type:       kvm
==> default:  -- Cpus:              2
==> default:  -- Feature:           acpi
==> default:  -- Feature:           apic
==> default:  -- Feature:           pae
==> default:  -- Memory:            1024M
==> default:  -- Management MAC:
==> default:  -- Loader:
==> default:  -- Base box:          viptela/vbond-vedge
==> default:  -- Storage pool:      default
==> default:  -- Image:             /var/lib/libvirt/images/viptela_default.img (11G)
==> default:  -- Volume Cache:      default
==> default:  -- Kernel:
==> default:  -- Initrd:
==> default:  -- Graphics Type:     vnc
==> default:  -- Graphics Port:     5900
==> default:  -- Graphics IP:       127.0.0.1
==> default:  -- Graphics Password: Not defined
==> default:  -- Video Type:        cirrus
==> default:  -- Video VRAM:        9216
==> default:  -- Sound Type:
==> default:  -- Keymap:            en-us
==> default:  -- TPM Path:
==> default:  -- INPUT:             type=mouse, bus=ps2
==> default: Creating shared folders metadata...
==> default: Starting domain.
==> default: Waiting for domain to get an IP address...
==> default: Waiting for SSH to become available...
==> default: Configuring and enabling network interfaces...

The guest operating system of the machine could not be detected!
Vagrant requires this knowledge to perform specific tasks such
as mounting shared folders and configuring networks. Please add
the ability to detect this guest operating system to Vagrant
by creating a plugin or reporting a bug.
Note
The error above relates to guest OS detection. The box built correctly and you can login and use the box as normal however, Vagrant could not detect the type of OS the box uses. Vagrant needs to know the OS type for provisioning purposes and since we are not doing any provisioning with Vagrant we can ignore it.

Now with that out of the way, lets test SSH to vBond/vEdge.

cmd
# from host shell

vagrant ssh

# now in vBond/vEdge shell

Welcome to Viptela CLI
vagrant connected from 192.168.121.1 using ssh on vedge
vedge# show version
16.3.2

Awesome, we are able to connect now lets clean up the box.

cmd
# from host shell

vagrant destroy -f

# output

==> default: Removing domain...

Outro

Now you a have disposable vBond/vEdge to add to the vManage created earlier.