Skip to content

A procedure for creating a Juniper vSRX Vagrant box for the libvirt provider.

License

Notifications You must be signed in to change notification settings

mweisel/juniper-vsrx-vagrant-libvirt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vagrant

Juniper vSRX Vagrant box

A procedure for creating a Juniper vSRX Vagrant box for the libvirt provider.

Prerequisites

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.6.3, global)

1. Download the vSRX (KVM) file from the Juniper website. Save it to your Downloads directory.

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

$ sudo cp $HOME/Downloads/junos-vsrx3-x86-64-21.2R1.10.qcow2 /var/lib/libvirt/images/juniper-vsrx.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/juniper-vsrx.qcow2
$ sudo chmod u+x /var/lib/libvirt/images/juniper-vsrx.qcow2

Arch Linux

$ sudo chown nobody:kvm /var/lib/libvirt/images/juniper-vsrx.qcow2
$ sudo chmod u+x /var/lib/libvirt/images/juniper-vsrx.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/juniper-vsrx-vagrant-libvirt
$ cd juniper-vsrx-vagrant-libvirt

7. Run the Ansible playbook.

$ ansible-playbook main.yml

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

$ cp juniper-vsrx.box $HOME/boxes/juniper-vsrx-21.2R1.box

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

$ cp ./files/juniper-vsrx.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}' juniper-vsrx.json
"url": "file://HOME/boxes/juniper-vsrx-VER.box"

$ sed -i "s|HOME|${HOME}|" juniper-vsrx.json

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

12. Also, substitute the VER placeholder string with your Juniper vSRX version.

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

$ sed -i 's/VER/21.2R1/g' juniper-vsrx.json

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

13. Add the Vagrant box to the local inventory.

$ vagrant box add --box-version 21.2R1 juniper-vsrx.json

Debug

To view the telnet session output for the expect task:

$ tail -f ~/vsrx-console.explog

License

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

About

A procedure for creating a Juniper vSRX Vagrant box for the libvirt provider.

Topics

Resources

License

Stars

Watchers

Forks

Languages