--- /dev/null
+# Purpose
+Creates VMs running CentOS 7.0 x64 with OpenVSwitch.
+Please use the Vagrant environment variable OVS_NODES to set the number of VMs that would be created. Default value is 2 (ovs1 and ovs2).
+
+# About the included OVS rpm
+To improve provisioning time, "openvswitch-2.3.1-1.x86_64.rpm" is pulled from dropbox. You can add rpm files for other OVS version if desired. Default ovs version is 2.3.1.
+
+To build ovs for the VMs from source, open the vagrant file and make changes to :
+
+Line 19: ovsversion = "<desired_ovs_release>"
+Line 50: puppet.manifest_file = "ovsnode_build.pp"
+
+
+
--- /dev/null
+# -*- mode: ruby -*-
+# # vi: set ft=ruby :
+
+# Specify minimum Vagrant version and Vagrant API version
+Vagrant.require_version ">= 1.6.0"
+VAGRANTFILE_API_VERSION = "2"
+
+# Create boxes
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+
+ # Get the number of OVS VMs to create
+ num_ovs_vms = (ENV['OVS_NODES'] || 2).to_i
+
+ base_name = "ovs"
+ base_ip = "192.168.100."
+ controller_ip = "192.168.100.10"
+ os = "puppetlabs/centos-7.0-64-puppet"
+ ram = "512"
+ ovsversion = "2.3.1"
+ ovs_node_ips = num_ovs_vms.times.collect { |n| base_ip + "#{n+21}" }
+
+ num_ovs_vms.times do |n|
+ config.vm.define base_name + "#{n+1}", autostart: true do |srv|
+ ## Extract yaml variables
+ hostname = base_name + "#{n+1}"
+ local_ip = ovs_node_ips[n]
+
+ srv.vm.hostname = hostname
+ srv.vm.box = os
+ srv.vm.network "private_network", ip: local_ip
+ srv.vm.provider :virtualbox do |vb|
+ vb.name = hostname
+ vb.memory = ram
+ end # vb
+
+ # Set guest environment variables
+ command1 = 'export CONTROLLER=\"' + controller_ip + '\"'
+ command2 = 'export LOCAL_IP=\"' + local_ip + '\"'
+ srv.vm.provision :shell, privileged: true, inline: 'echo ' + command1 + ' >> /etc/profile'
+ srv.vm.provision :shell, privileged: true, inline: 'echo ' + command2 + ' >> /etc/profile'
+ srv.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
+
+ ## SSH config
+ srv.ssh.forward_x11 = false
+
+ ## puppet
+ srv.vm.provision "puppet" do |puppet|
+ puppet.working_directory = "/vagrant/puppet"
+ puppet.manifests_path = "puppet/manifests"
+ puppet.manifest_file = "ovsnode.pp"
+ puppet.options = "--verbose --debug"
+ puppet.facter = {
+ "ovsversion" => ovsversion,
+ }
+ end # puppet
+
+
+ #process setup commands for ovs
+ srv.vm.provision "shell", path: "puppet/scripts/setup_defaults.sh"
+
+ end # srv
+ end #end num_ovs_vms
+end # config
--- /dev/null
+ $base_packages = [
+ "kernel-headers",
+ "kernel-devel",
+ "gcc",
+ "make",
+ "python-devel",
+ "openssl-devel",
+ "graphviz",
+ "kernel-debug-devel",
+ "automake",
+ "rpm-build",
+ "redhat-rpm-config",
+ "libtool",
+ "git"
+ ]
+
+ package { $base_packages:
+ ensure => installed,
+ }
+
+ notice("Dependencies are ready!")
--- /dev/null
+ notice("specified ovs version to install: ${ovsversion}")
+
+ exec { "mktarget":
+ command => "/bin/mkdir -p /vagrant/shared/",
+ cwd => "/",
+ }
+
+ file { [
+ "/vagrant/shared/",
+ ]:
+ ensure => directory,
+ }
+
+ exec { "download_ovs":
+ command => "/usr/bin/wget https://www.dropbox.com/s/v34fbw6t0mvtoi8/openvswitch-${ovsversion}-1.x86_64.rpm?dl=0 -O /vagrant/shared/openvswitch-${ovsversion}-1.x86_64.rpm",
+ cwd => "/root",
+ creates => "/vagrant/shared/openvswitch-${ovsversion}-1.x86_64.rpm",
+ require => [
+ Exec["mktarget"],
+ ],
+ }
+
+ exec { "install_ovs":
+ command => "yum localinstall -y /vagrant/shared/openvswitch-${ovsversion}-1.x86_64.rpm",
+ cwd => "/root",
+ path => ["/bin", "/usr/bin"],
+ require => [
+ Exec["download_ovs"],
+ ],
+ }
+
+ exec { "start_ovs":
+ command => "systemctl start openvswitch.service",
+ require => [
+ Exec["install_ovs"],
+ ],
+ cwd => "/root",
+ path => ["/bin", "/usr/bin"],
+ }
--- /dev/null
+ import 'dependencies.pp'
+
+ notice("specified ovs version to install: ${ovsversion}")
+
+ exec { "mksource":
+ command => "/bin/mkdir -p /rpmbuild/SOURCES/",
+ cwd => "/",
+ }
+
+ file { [
+ "/rpmbuild/",
+ "/rpmbuild/SOURCES/",
+ ]:
+ ensure => directory,
+ }
+
+ exec { "download_ovs":
+ command => "wget http://openvswitch.org/releases/openvswitch-${ovsversion}.tar.gz -O /root/openvswitch-${ovsversion}.tar.gz",
+ creates => "/root/openvswitch-${ovsversion}.tar.gz",
+ cwd => "/root",
+ path => ["/bin", "/usr/bin"],
+ }
+
+ exec { "check_presence":
+ command => "true",
+ onlyif => "/usr/bin/test -e /rpmbuild/SOURCES",
+ path => ["/bin", "/usr/bin"],
+ }
+
+ exec { "copy_archive":
+ command => "cp /root/openvswitch-${ovsversion}.tar.gz /rpmbuild/SOURCES/openvswitch-${ovsversion}.tar.gz",
+ require => [
+ Exec["mksource"],
+ Exec["download_ovs"],
+ Exec["check_presence"],
+ ],
+ cwd => "/root",
+ creates => "/rpmbuild/SOURCES/openvswitch-${ovsversion}.tar.gz",
+ path => ["/bin", "/usr/bin"],
+ }
+
+ exec { "extract_ovs":
+ command => "tar xvfz /root/openvswitch-${ovsversion}.tar.gz",
+ require => [
+ Exec["copy_archive"],
+ ],
+ path => ["/bin", "/usr/bin"],
+ cwd => "/root",
+ creates => "/root/openvswitch-${ovsversion}/README",
+ }
+
+ exec { "custom_sed":
+ command => "sed 's/openvswitch-kmod, //g' /root/openvswitch-${ovsversion}/rhel/openvswitch.spec > /root/openvswitch-${ovsversion}/rhel/openvswitch_no_kmod.spec",
+ require => [
+ Exec["extract_ovs"],
+ ],
+ cwd => "/root",
+ path => ["/bin", "/usr/bin"],
+ }
+
+ exec { "build_ovs":
+ command => "rpmbuild -bb --nocheck /root/openvswitch-${ovsversion}/rhel/openvswitch_no_kmod.spec",
+ cwd => "/root",
+ path => ["/bin", "/usr/bin"],
+ require => [
+ Exec["custom_sed"],
+ ],
+ timeout => 0,
+ creates => "/root/rpmbuild/RPMS/x86_64/openvswitch-${ovsversion}-1.x86_64.rpm",
+ }
+
+ exec { "install_ovs":
+ command => "yum localinstall -y /rpmbuild/RPMS/x86_64/openvswitch-${ovsversion}-1.x86_64.rpm",
+ cwd => "/root",
+ path => ["/bin", "/usr/bin"],
+ require => [
+ Exec["build_ovs"],
+ ],
+ }
+
+ exec { "start_ovs":
+ command => "systemctl start openvswitch.service",
+ require => [
+ Exec["install_ovs"],
+ ],
+ cwd => "/root",
+ path => ["/bin", "/usr/bin"],
+ }
--- /dev/null
+#!/usr/bin/env bash
+#
+
+sudo service openvswitch-switch stop
+sudo rm -rf /var/log/openvswitch/*
+sudo rm -rf /etc/openvswitch/conf.db
+sudo service openvswitch-switch start
+
--- /dev/null
+# add a bridge
+sudo ovs-vsctl add-br ovs-br0
+
+# add a port to the bridge
+#sudo ovs-vsctl add-port ovs-br0 eth1
+
+# link the bridge the controller
+sudo ovs-vsctl set-controller ovs-br0 tcp:$CONTROLLER:6633
+
+# link the controller as a manager
+sudo ovs-vsctl set-manager tcp:$CONTROLLER:6640