Add Vagrantfile for OVSDB Test/Dev environment 81/5981/8
authorDave Tucker <dave@dtucker.co.uk>
Tue, 8 Apr 2014 19:40:05 +0000 (20:40 +0100)
committerDave Tucker <dave@dtucker.co.uk>
Tue, 13 May 2014 03:05:00 +0000 (04:05 +0100)
This commit adds a Vagrantfile to the root of the repository. This
allows a developer to issue a single command to pull up a development
and test environment:

    vagrant up

This will create 3 x VMs in Virtual Box. VMs can be
created individually if required.

1 x VM for Mininet - 2GB RAM
1 x DevStack Control/Compute node - 4GB RAM
1 x DevStack Compute node) - 4GB RAM

See README.Vagrant for full instructions

Change-Id: Ieaaec6cde09ce9ecc7b31861f86695c662849f7d
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
13 files changed:
.gitignore
README.Vagrant [new file with mode: 0644]
Vagrantfile [new file with mode: 0644]
resources/puppet/hiera.yaml [new file with mode: 0644]
resources/puppet/hieradata/hosts.json [new file with mode: 0644]
resources/puppet/manifests/base.pp [new file with mode: 0644]
resources/puppet/manifests/devstack-compute.pp [new file with mode: 0644]
resources/puppet/manifests/devstack-control.pp [new file with mode: 0644]
resources/puppet/manifests/mininet.pp [new file with mode: 0644]
resources/puppet/scripts/bootstrap.sh [new file with mode: 0644]
resources/puppet/templates/compute.local.conf.erb [new file with mode: 0644]
resources/puppet/templates/control.local.conf.erb [new file with mode: 0644]
resources/puppet/templates/hosts.erb [new file with mode: 0644]

index e04ff826c68b5c19d8b52848c6b50e9f936c3f49..3801de5b7d4c0bb5d78f4bd720d8660d77d3eedb 100755 (executable)
@@ -15,3 +15,5 @@ target
 .project\r
 .settings\r
 MANIFEST.MF\r
+.vagrant\r
+.DS_Store\r
diff --git a/README.Vagrant b/README.Vagrant
new file mode 100644 (file)
index 0000000..3651093
--- /dev/null
@@ -0,0 +1,69 @@
+ODL OVSDB Vagrant
+=================
+
+# Installation
+
+You can download an install for your system from [here](http://www.vagrantup.com/downloads.html)
+Vagrant can also be installed using RubyGems
+
+    gem install vagrant
+
+# Usage
+
+Vagrant is a tool for creating development/test environments.
+The environment created for this project is as follows:
+
+1 x DevStack Control/Compute VM
+1 x DevStack Compute VM
+1 x Mininet VM
+
+It's assumed you already have an OVSDB development environment set up.
+
+1. Run `mvn clean install`
+2. Run `vagrant up`
+3. Start the controller (in distirbution/target/opendaylight/...)
+
+> Note: It's assumed that the subnet 192.168.50.x/24 is not in use
+> Your PC is 192.168.50.1. If you would like to change the addressing,
+> you will need to edit the Vagrantfile and hosts.json
+
+Follow the instructions below for Devstack and Mininet
+
+## DevStack VMs
+
+There are two DevStack VMs. One combined control/compute node and one dedicated compute node.
+The following steps are performed when the VM is created or when `vagrant provision` is run.
+
+- Check dependencies are installed
+- Clone the devstack repository to `devstack`
+- Generate a `local.conf` file
+
+To start DevStack
+
+    vagrant ssh devstack-control
+    # or vagrant ssh devstack-compute
+    cd devstack
+    ./stack.sh
+
+## Mininet
+
+There is a single VM provided for running mininet.
+This is for testing that does not require OpenStack Neutron.
+
+The following steps are performed when the VM is created or when `vagrant provision` is run.
+- Check dependencies are installed
+- Clone the mininet repository
+- Install mininet and Open vSwitch
+
+To start Mininet
+
+    vagrant ssh mininet
+    sudo mn
+
+# Port Forwarding
+
+The following ports are forwarded:
+
+localhost:8080 -> opendaylight:8080
+localhost:8000 -> opendaylight:8000
+localhost:8081 -> devstack-control:8080
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644 (file)
index 0000000..7874d9f
--- /dev/null
@@ -0,0 +1,64 @@
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+
+  config.vm.provision "shell", path: "resources/puppet/scripts/bootstrap.sh"
+
+  config.vm.provision "puppet" do |puppet|
+      puppet.hiera_config_path = "resources/puppet/hiera.yaml"
+      puppet.working_directory = "/vagrant/resources/puppet"
+      puppet.manifests_path = "resources/puppet/manifests"
+      puppet.manifest_file  = "base.pp"
+  end
+
+  config.vm.define "mininet" do |mininet|
+    mininet.vm.box = "saucy64"
+    mininet.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box"
+    mininet.vm.hostname = "mininet"
+    mininet.vm.network "private_network", ip: "192.168.50.15"
+    mininet.vm.provider :virtualbox do |vb|
+      vb.memory = 2048
+    end
+    mininet.vm.provision "puppet" do |puppet|
+      puppet.hiera_config_path = "resources/puppet/hiera.yaml"
+      puppet.working_directory = "/vagrant/resources/puppet"
+      puppet.manifests_path = "resources/puppet/manifests"
+      puppet.manifest_file  = "mininet.pp"
+    end
+  end
+
+  config.vm.define "devstack-control" do |dsctl|
+    dsctl.vm.box = "saucy64"
+    dsctl.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box"
+    dsctl.vm.hostname = "devstack-control"
+    dsctl.vm.network "private_network", ip: "192.168.50.20"
+    dsctl.vm.network "forwarded_port", guest: 8080, host: 8081
+    dsctl.vm.provider :virtualbox do |vb|
+      vb.memory = 4096
+    end
+    dsctl.vm.provision "puppet" do |puppet|
+      puppet.hiera_config_path = "resources/puppet/hiera.yaml"
+      puppet.working_directory = "/vagrant/resources/puppet"
+      puppet.manifests_path = "resources/puppet/manifests"
+      puppet.manifest_file  = "devstack-control.pp"
+    end
+  end
+
+  config.vm.define "devstack-compute" do |dscom|
+    dscom.vm.box = "saucy64"
+    dscom.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box"
+    dscom.vm.hostname = "devstack-compute"
+    dscom.vm.network "private_network", ip: "192.168.50.21"
+    dscom.vm.provider :virtualbox do |vb|
+      vb.memory = 4096
+    end
+    dscom.vm.provision "puppet" do |puppet|
+      puppet.hiera_config_path = "resources/puppet/hiera.yaml"
+      puppet.working_directory = "/vagrant/resources/puppet"
+      puppet.manifests_path = "resources/puppet/manifests"
+      puppet.manifest_file  = "devstack-compute.pp"
+    end
+  end
+
+end
diff --git a/resources/puppet/hiera.yaml b/resources/puppet/hiera.yaml
new file mode 100644 (file)
index 0000000..8e2f646
--- /dev/null
@@ -0,0 +1,10 @@
+---
+:backends:
+  - yaml
+  - json
+:yaml:
+  :datadir: /vagrant/resources/puppet/hieradata
+:json:
+  :datadir: /vagrant/resources/puppet/hieradata
+:hierarchy:
+  - hosts
diff --git a/resources/puppet/hieradata/hosts.json b/resources/puppet/hieradata/hosts.json
new file mode 100644 (file)
index 0000000..74ef641
--- /dev/null
@@ -0,0 +1,20 @@
+{
+  "hosts": {
+    "opendaylight": {
+      "name": "opendaylight",
+      "ipaddress": "192.168.50.1"
+    },
+    "mininet": {
+      "name": "mininet",
+      "ipaddress": "192.168.50.15"
+    },
+    "devstack-control": {
+      "name": "devstack-control",
+      "ipaddress": "192.168.50.20"
+    },
+    "devstack-compute": {
+      "name": "devstack-compute",
+      "ipaddress": "192.168.50.21"
+    }
+  }
+}
diff --git a/resources/puppet/manifests/base.pp b/resources/puppet/manifests/base.pp
new file mode 100644 (file)
index 0000000..3f095f2
--- /dev/null
@@ -0,0 +1,12 @@
+package {"git":
+    ensure => "installed"
+}
+
+$hosts = hiera('hosts')
+
+file { "/etc/hosts":
+    ensure => file,
+    owner => "root",
+    group => "root",
+    content => template('/vagrant/resources/puppet/templates/hosts.erb')
+}
diff --git a/resources/puppet/manifests/devstack-compute.pp b/resources/puppet/manifests/devstack-compute.pp
new file mode 100644 (file)
index 0000000..96cb1c2
--- /dev/null
@@ -0,0 +1,16 @@
+vcsrepo { "/home/vagrant/devstack":
+    provider => git,
+    ensure => present,
+    user => "vagrant",
+    source => "https://github.com/openstack-dev/devstack.git",
+    before => File['/home/vagrant/devstack/local.conf']
+}
+
+$hosts = hiera('hosts')
+
+file { "/home/vagrant/devstack/local.conf":
+    ensure => present,
+    owner => "vagrant",
+    group => "vagrant",
+    content => template('/vagrant/resources/puppet/templates/compute.local.conf.erb')
+}
diff --git a/resources/puppet/manifests/devstack-control.pp b/resources/puppet/manifests/devstack-control.pp
new file mode 100644 (file)
index 0000000..0c35e4f
--- /dev/null
@@ -0,0 +1,16 @@
+vcsrepo { "/home/vagrant/devstack":
+    provider => git,
+    ensure => present,
+    user => "vagrant",
+    source => "https://github.com/openstack-dev/devstack.git",
+    before => File['/home/vagrant/devstack/local.conf']
+}
+
+$hosts = hiera('hosts')
+
+file { "/home/vagrant/devstack/local.conf":
+    ensure => present,
+    owner => "vagrant",
+    group => "vagrant",
+    content => template('/vagrant/resources/puppet/templates/control.local.conf.erb')
+}
diff --git a/resources/puppet/manifests/mininet.pp b/resources/puppet/manifests/mininet.pp
new file mode 100644 (file)
index 0000000..98ae327
--- /dev/null
@@ -0,0 +1,15 @@
+vcsrepo { "/home/vagrant/mininet":
+    provider => git,
+    ensure => present,
+    user => "vagrant",
+    source => "git://github.com/mininet/mininet",
+    revision => '2.1.0p1',
+    before => Exec['Install Mininet']
+}
+
+exec { "Install Mininet":
+    command => "/bin/bash mininet/util/install.sh -nfv > /dev/null",
+    cwd => '/home/vagrant',
+    user => 'vagrant',
+    timeout => 0
+}
diff --git a/resources/puppet/scripts/bootstrap.sh b/resources/puppet/scripts/bootstrap.sh
new file mode 100644 (file)
index 0000000..6895b7d
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+#
+# This bootstraps Puppet on Ubuntu 12.04 LTS.
+#
+set -e
+
+# Load up the release information
+. /etc/lsb-release
+
+REPO_DEB_URL="http://apt.puppetlabs.com/puppetlabs-release-${DISTRIB_CODENAME}.deb"
+
+#--------------------------------------------------------------------
+# NO TUNABLES BELOW THIS POINT
+#--------------------------------------------------------------------
+if [ "$(id -u)" != "0" ]; then
+      echo "This script must be run as root." >&2
+        exit 1
+    fi
+
+    if which puppet > /dev/null 2>&1; then
+          echo "Puppet is already installed."
+            exit 0
+    fi
+
+    # Do the initial apt-get update
+    echo "Initial apt-get update..."
+    apt-get update >/dev/null
+
+    # Install wget if we have to (some older Ubuntu versions)
+    echo "Installing wget..."
+    apt-get install -y wget >/dev/null
+
+    # Install the PuppetLabs repo
+    echo "Configuring PuppetLabs repo..."
+    repo_deb_path=$(mktemp)
+    wget --output-document="${repo_deb_path}" "${REPO_DEB_URL}" 2>/dev/null
+    dpkg -i "${repo_deb_path}" >/dev/null
+    apt-get update >/dev/null
+
+    # Install Puppet
+    echo "Installing Puppet..."
+    apt-get install -y puppet >/dev/null
+
+    echo "Puppet installed!"
+
+    # Install RubyGems for the provider
+    echo "Installing RubyGems..."
+    apt-get install -y rubygems >/dev/null
+    gem install --no-ri --no-rdoc rubygems-update
+    update_rubygems >/dev/null
+
+    # Installing Puppet Modules
+    puppet module install puppetlabs/vcsrepo
+    puppet module install puppetlabs/stdlib
+
+
diff --git a/resources/puppet/templates/compute.local.conf.erb b/resources/puppet/templates/compute.local.conf.erb
new file mode 100644 (file)
index 0000000..0619f2c
--- /dev/null
@@ -0,0 +1,55 @@
+[[local|localrc]]
+SCREEN_LOGDIR=/opt/stack/log
+LOGFILE=stack.sh.log
+LOG_COLOR=False
+#OFFLINE=True
+#RECLONE=yes
+
+HOST_IP=<%= @hosts['devstack-compute']['ipaddress'] %>
+HOST_NAME=<%= @hosts['devstack-compute']['name'] %>
+SERVICE_HOST=<%= @hosts['devstack-control']['name'] %>
+SERVICE_HOST_NAME=<%= @hosts['devstack-control']['name'] %>
+
+Q_HOST=$SERVICE_HOST
+MYSQL_HOST=$SERVICE_HOST
+RABBIT_HOST=$SERVICE_HOST
+GLANCE_HOSTPORT=$SERVICE_HOST:9292
+KEYSTONE_AUTH_HOST=$SERVICE_HOST
+KEYSTONE_SERVICE_HOST=$SERVICE_HOST
+
+MYSQL_PASSWORD=mysql
+RABBIT_PASSWORD=rabbit
+QPID_PASSWORD=rabbit
+SERVICE_TOKEN=service
+SERVICE_PASSWORD=admin
+ADMIN_PASSWORD=admin
+
+VNCSERVER_PROXYCLIENT_ADDRESS=$HOST_IP
+VNCSERVER_LISTEN=0.0.0.0
+
+disable_all_services
+enable_service neutron quantum nova n-cpu n-novnc rabbit odl-compute
+
+# ODL WITH ML2
+Q_PLUGIN=ml2
+Q_ML2_PLUGIN_MECHANISM_DRIVERS=opendaylight,logger
+ODL_MGR_IP=<%= @hosts['opendaylight']['ipaddress'] %>
+
+ENABLE_TENANT_TUNNELS=True
+# Q_ML2_TENANT_NETWORK_TYPE=vlan
+# ENABLE_TENANT_VLANS=True
+Q_ML2_TENANT_NETWORK_TYPE=vxlan
+#Q_AGENT_EXTRA_AGENT_OPTS=(tunnel_types=vxlan)
+
+#FLOATING_RANGE=192.168.254.64/26
+
+EXTRA_OPTS=(scheduler_default_filters=AllHostsFilter)
+
+[[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]
+[agent]
+minimize_polling=True
+
+[ml2_odl]
+url=http://<%= @hosts['opendaylight']['ipaddress'] %>:8080/controller/nb/v2/neutron
+username=admin
+password=admin
diff --git a/resources/puppet/templates/control.local.conf.erb b/resources/puppet/templates/control.local.conf.erb
new file mode 100644 (file)
index 0000000..563d5a9
--- /dev/null
@@ -0,0 +1,64 @@
+[[local|localrc]]
+SCREEN_LOGDIR=/opt/stack/log
+LOGFILE=stack.sh.log
+LOG_COLOR=False
+#OFFLINE=True
+RECLONE=yes
+
+HOST_IP=<%= @hosts['devstack-control']['ipaddress'] %>
+HOST_NAME=<%= @hosts['devstack-control']['name'] %>
+SERVICE_HOST=$HOST_IP
+SERVICE_HOST_NAME=$HOST_NAME
+
+Q_HOST=$SERVICE_HOST
+MYSQL_HOST=$SERVICE_HOST
+RABBIT_HOST=$SERVICE_HOST
+GLANCE_HOSTPORT=$SERVICE_HOST:9292
+KEYSTONE_AUTH_HOST=$SERVICE_HOST
+KEYSTONE_SERVICE_HOST=$SERVICE_HOST
+
+MYSQL_PASSWORD=mysql
+RABBIT_PASSWORD=rabbit
+QPID_PASSWORD=rabbit
+SERVICE_TOKEN=service
+SERVICE_PASSWORD=admin
+ADMIN_PASSWORD=admin
+
+enable_service rabbit
+disable_service qpid
+
+enable_service n-cond
+enable_service n-cpu
+enable_service n-novnc
+disable_service n-net
+enable_service q-svc
+# enable_service q-agt
+enable_service q-dhcp
+enable_service q-l3
+enable_service q-meta
+enable_service quantum
+enable_service odl-compute
+
+# ODL WITH ML2
+Q_PLUGIN=ml2
+Q_ML2_PLUGIN_MECHANISM_DRIVERS=opendaylight,logger
+ODL_MGR_IP=<%= @hosts['opendaylight']['ipaddress'] %>
+
+ENABLE_TENANT_TUNNELS=True
+# ENABLE_TENANT_VLANS=True
+# TENANT_VLAN_RANGE=500:510
+
+Q_ML2_TENANT_NETWORK_TYPE=vxlan
+# Q_AGENT_EXTRA_AGENT_OPTS=(tunnel_types=vxlan)
+
+#FLOATING_RANGE=192.168.254.64/26
+#PUBLIC_NETWORK_GATEWAY=192.168.75.254
+
+[[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]
+[agent]
+minimize_polling=True
+
+[ml2_odl]
+url=http://<%= @hosts['opendaylight']['ipaddress'] %>:8080/controller/nb/v2/neutron
+username=admin
+password=admin
diff --git a/resources/puppet/templates/hosts.erb b/resources/puppet/templates/hosts.erb
new file mode 100644 (file)
index 0000000..c23f40f
--- /dev/null
@@ -0,0 +1,8 @@
+## Do Not Edit. Created by Puppet ##
+127.0.0.1   localhost
+255.255.255.255 broadcasthost
+::1             localhost
+fe80::1%lo0 localhost
+<% @hosts.values.each do |h| %>
+<%= h["ipaddress"] %>  <%= h["name"] %>
+<% end %>