summaryrefslogtreecommitdiff
path: root/vagrant
diff options
context:
space:
mode:
Diffstat (limited to 'vagrant')
-rw-r--r--vagrant/.env.example13
-rw-r--r--vagrant/VAGRANT.md35
-rw-r--r--vagrant/Vagrantfile50
3 files changed, 98 insertions, 0 deletions
diff --git a/vagrant/.env.example b/vagrant/.env.example
new file mode 100644
index 0000000..36bebf8
--- /dev/null
+++ b/vagrant/.env.example
@@ -0,0 +1,13 @@
+
+# vyos https api key
+VYDEVICE_APIKEY=your_api_key
+
+# vyos network interface
+VYDEVICE_IP=192.168.56.10
+VYDEVICE_NETMASK=255.255.255.0
+
+# HOST_IP is the ip address of the host machine of the virtualbox
+# use your windows network interface for virtualbox running on windows host and using wsl2 for vagrant
+HOST_IP=192.168.0.114
+# or use 127.0.0.1, virtualbox running on linux host or windows host
+# HOST_IP=127.0.0.1 \ No newline at end of file
diff --git a/vagrant/VAGRANT.md b/vagrant/VAGRANT.md
new file mode 100644
index 0000000..fab5e59
--- /dev/null
+++ b/vagrant/VAGRANT.md
@@ -0,0 +1,35 @@
+# Vagrant only for development and tests
+
+Vagrant is a tool for building and managing virtual machine environments
+in pyvyos we use vagrant to deploy vyos virtual machines
+for development and automated tests
+
+If you want to only use pyvyos you dont need to install vagrant
+
+# Vagrant install instructions
+
+1. Install Vagrant
+2. Install VirtualBox
+3. Install Vagrant plugin for vyos
+```
+vagrant plugin install vagrant-vyos
+```
+4. Install mkisofs
+```
+sudo apt install genisoimage
+```
+
+5. Run vagrant up
+```
+vagrant up
+```
+6. Run vagrant ssh
+```
+vagrant ssh
+```
+
+# For Windows with wsl2:
+```
+export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
+export PATH="$PATH:/mnt/c/Program Files/Oracle/VirtualBox"
+``` \ No newline at end of file
diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile
new file mode 100644
index 0000000..89edbf3
--- /dev/null
+++ b/vagrant/Vagrantfile
@@ -0,0 +1,50 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# Documentation:
+# - read VAGRANT.md
+# - need vagrant plugin install vagrant-vyos
+
+Vagrant.configure("2") do |config|
+ # enable the environment variables
+ # need vagrant plugin install vagrant-dotenv
+ config.env.enable
+
+ # vm to deploy tests
+ config.vm.define "pyvyos" do |pyvyos|
+ pyvyos.vm.box = "vyos/current"
+ pyvyos.vm.hostname = "pyvyos"
+
+ # network configuration of eth1
+ pyvyos.vm.network "private_network", ip: ENV['VYDEVICE_IP'], netmask: ENV['VYDEVICE_NETMASK']
+ pyvyos.ssh.host = ENV['HOST_IP']
+
+ # nat port forwarding
+ pyvyos.vm.network "forwarded_port", guest: 443, host: 8433, id: "https", auto_correct: true, protocol: "tcp", host_ip: ENV['HOST_IP']
+ pyvyos.vm.network "forwarded_port", guest: 22, host: 2022, id: "ssh", auto_correct: true, protocol: "tcp", host_ip: ENV['HOST_IP']
+
+ # ssh configuration default username and password of vyos/current is vyos / vyos
+ # if you want to change the default password, you can change in provision script
+ # also, you can disable ssh password in provision script and use only ssh key
+ pyvyos.ssh.username = "vyos"
+ pyvyos.ssh.password = "vyos"
+
+ # vagrant will insert the ssh key in the vm automatically, so password authentication after
+ # first boot is not necessary
+ pyvyos.ssh.insert_key = true
+
+ # shell script to provision the vyos vm
+ pyvyos.vm.provision "shell", inline: <<-SHELL
+ #!/bin/vbash
+ source /opt/vyatta/etc/functions/script-template
+ configure
+ set service https listen-address '#{ENV['VYDEVICE_IP']}'
+ set service https api keys id 'apikey' key '#{ENV['VYDEVICE_APIKEY']}'
+ set service https api debug
+ set service https api strict
+ commit
+ save
+ exit
+ SHELL
+ end
+ end