mweisel / cisco-csr1kv-vagrant-libvirt

A procedure for creating a Cisco CSR 1000V Vagrant box for the libvirt provider.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vagrant

Cisco CSR 1000V Vagrant box

A procedure for creating a Cisco CSR 1000V (Cisco IOS XE Denali 16.3.1 or later) Vagrant box for the libvirt provider.

Prerequisites

Vagrant version 2.2.16 introduced a bug that breaks SSH connectivity - #12344

Steps

0. Verify the prerequisite tools are installed.

$ which git python ansible libvirtd virsh qemu-system-x86_64 expect telnet vagrant
$ vagrant plugin list
vagrant-libvirt (0.5.1, global)

1. Log in and download the Cisco Cloud Services Router 1000V software from your Cisco account. Save the file to your Downloads directory.

2. Copy (and rename) the disk image file to the /var/lib/libvirt/images directory.

$ sudo cp $HOME/Downloads/csr1000v-universalk9.17.03.02-serial.qcow2 /var/lib/libvirt/images/cisco-csr1kv.qcow2

3. Modify the file ownership and permissions. Note the owner may differ between Linux distributions.

Ubuntu 18.04

$ sudo chown libvirt-qemu:kvm /var/lib/libvirt/images/cisco-csr1kv.qcow2
$ sudo chmod u+x /var/lib/libvirt/images/cisco-csr1kv.qcow2

Arch Linux

$ sudo chown nobody:kvm /var/lib/libvirt/images/cisco-csr1kv.qcow2
$ sudo chmod u+x /var/lib/libvirt/images/cisco-csr1kv.qcow2

4. Create the boxes directory.

$ mkdir -p $HOME/boxes

5. Start the vagrant-libvirt network (if not already started).

$ virsh -c qemu:///system net-list
$ virsh -c qemu:///system net-start vagrant-libvirt

6. Clone this GitHub repo and cd into the directory.

$ git clone https://github.com/mweisel/cisco-csr1kv-vagrant-libvirt
$ cd cisco-csr1kv-vagrant-libvirt

7. Run the Ansible playbook.

$ ansible-playbook main.yml

8. Copy (and rename) the Vagrant box artifact to the boxes directory.

$ cp cisco-csr1kv.box $HOME/boxes/cisco-csr1000v-17.03.02.box

9. Copy the box metadata file to the boxes directory.

$ cp ./files/cisco-csr1000v.json $HOME/boxes/

10. Change the current working directory to boxes.

$ cd $HOME/boxes

11. Substitute the HOME placeholder string in the box metadata file.

$ awk '/url/{gsub(/^ */,"");print}' cisco-csr1000v.json
"url": "file://HOME/boxes/cisco-csr1000v-VER.box"

$ sed -i "s|HOME|${HOME}|" cisco-csr1000v.json

$ awk '/url/{gsub(/^ */,"");print}' cisco-csr1000v.json
"url": "file:///home/marc/boxes/cisco-csr1000v-VER.box"

12. Also, substitute the VER placeholder string with the Cisco IOS XE version you're using.

$ awk '/VER/{gsub(/^ */,"");print}' cisco-csr1000v.json
"version": "VER",
"url": "file:///home/marc/boxes/cisco-csr1000v-VER.box"

$ sed -i 's/VER/17.03.02/g' cisco-csr1000v.json

$ awk '/\<version\>|url/{gsub(/^ */,"");print}' cisco-csr1000v.json
"version": "17.03.02",
"url": "file:///home/marc/boxes/cisco-csr1000v-17.03.02.box"

13. Add the Vagrant box to the local inventory.

$ vagrant box add cisco-csr1000v.json

Debug

To view the telnet session output for the expect task:

$ tail -f ~/csr1kv-console.explog

License

This project is licensed under the MIT License - see the LICENSE file for details

About

A procedure for creating a Cisco CSR 1000V Vagrant box for the libvirt provider.

License:MIT License


Languages

Language:Shell 100.0%