From fdfa12e1dd2747a64d72263a4eec99fda549123a Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Thu, 24 Jul 2014 15:03:34 +0100 Subject: [PATCH] Initial Commit of ODL OpenStack Integration - Add Vagrantfile for Devstack VMs - Add Puppet manifests for provisioning the VMs Change-Id: I099dd25feb2bdeafee6ef360b346cbe10ab9ac00 Signed-off-by: Dave Tucker --- .gitignore | 1 + .../odl-openstack-integration/Vagrantfile | 186 ++++++++++++++++++ .../puppet/hiera.yaml | 10 + .../puppet/hieradata/hosts.json | 20 ++ .../puppet/manifests/base.pp | 12 ++ .../puppet/manifests/devstack-compute.pp | 17 ++ .../puppet/manifests/devstack-control.pp | 17 ++ .../puppet/scripts/bootstrap.sh | 56 ++++++ .../puppet/templates/compute.local.conf.erb | 55 ++++++ .../puppet/templates/control.local.conf.erb | 64 ++++++ .../puppet/templates/hosts.erb | 8 + 11 files changed, 446 insertions(+) create mode 100644 test/tools/odl-openstack-integration/Vagrantfile create mode 100644 test/tools/odl-openstack-integration/puppet/hiera.yaml create mode 100644 test/tools/odl-openstack-integration/puppet/hieradata/hosts.json create mode 100644 test/tools/odl-openstack-integration/puppet/manifests/base.pp create mode 100644 test/tools/odl-openstack-integration/puppet/manifests/devstack-compute.pp create mode 100644 test/tools/odl-openstack-integration/puppet/manifests/devstack-control.pp create mode 100644 test/tools/odl-openstack-integration/puppet/scripts/bootstrap.sh create mode 100644 test/tools/odl-openstack-integration/puppet/templates/compute.local.conf.erb create mode 100644 test/tools/odl-openstack-integration/puppet/templates/control.local.conf.erb create mode 100644 test/tools/odl-openstack-integration/puppet/templates/hosts.erb diff --git a/.gitignore b/.gitignore index 1a1781c923..1b97d3d434 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ log.html output.xml report.html *.swp +.vagrant diff --git a/test/tools/odl-openstack-integration/Vagrantfile b/test/tools/odl-openstack-integration/Vagrantfile new file mode 100644 index 0000000000..2172ec0747 --- /dev/null +++ b/test/tools/odl-openstack-integration/Vagrantfile @@ -0,0 +1,186 @@ +# 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: "puppet/scripts/bootstrap.sh" + + config.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "base.pp" + end + + config.vm.define "ds-ctl-havana" do |dsctlh| + dsctlh.vm.box = "saucy64" + dsctlh.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box" + dsctlh.vm.hostname = "ds-ctl" + dsctlh.vm.network "private_network", ip: "192.168.50.20" + dsctlh.vm.provider :virtualbox do |vb| + vb.memory = 4096 + end + dsctlh.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "devstack-control.pp" + puppet.facter = { + "devstack_branch" => "stable/havana" + } + end + end + + config.vm.define "ds-c1-havana" do |dsc1h| + dsc1h.vm.box = "saucy64" + dsc1h.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box" + dsc1h.vm.hostname = "ds-c1" + dsc1h.vm.network "private_network", ip: "192.168.50.21" + dsc1h.vm.provider :virtualbox do |vb| + vb.memory = 4096 + end + dsc1h.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "ds-compute.pp" + puppet.facter = { + "devstack_branch" => "stable/havana" + } + end + end + + config.vm.define "ds-c2-havana" do |dsc2h| + dsc2h.vm.box = "saucy64" + dsc2h.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box" + dsc2h.vm.hostname = "ds-c2" + dsc2h.vm.network "private_network", ip: "192.168.50.22" + dsc2h.vm.provider :virtualbox do |vb| + vb.memory = 4096 + end + dsc2h.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "ds-compute.pp" + puppet.facter = { + "devstack_branch" => "stable/havana" + } + end + end + + config.vm.define "ds-ctl-icehouse" do |dsctli| + dsctli.vm.box = "saucy64" + dsctli.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box" + dsctli.vm.hostname = "ds-ctl" + dsctli.vm.network "private_network", ip: "192.168.50.20" + dsctli.vm.provider :virtualbox do |vb| + vb.memory = 4096 + end + dsctli.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "devstack-control.pp" + puppet.facter = { + "devstack_branch" => "stable/icehouse" + } + end + end + + config.vm.define "ds-c1-icehouse" do |dsc1i| + dsc1i.vm.box = "saucy64" + dsc1i.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box" + dsc1i.vm.hostname = "ds-c1" + dsc1i.vm.network "private_network", ip: "192.168.50.21" + dsc1i.vm.provider :virtualbox do |vb| + vb.memory = 4096 + end + dsc1i.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "devstack-compute.pp" + puppet.facter = { + "devstack_branch" => "stable/icehouse" + } + end + end + + config.vm.define "ds-c2-icehouse" do |dsc2i| + dsc2i.vm.box = "saucy64" + dsc2i.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box" + dsc2i.vm.hostname = "ds-c2" + dsc2i.vm.network "private_network", ip: "192.168.50.22" + dsc2i.vm.provider :virtualbox do |vb| + vb.memory = 4096 + end + dsc2i.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "devstack-compute.pp" + puppet.facter = { + "devstack_branch" => "stable/icehouse" + } + end + end + + config.vm.define "ds-ctl-juno" do |dsctlj| + dsctlj.vm.box = "saucy64" + dsctlj.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box" + dsctlj.vm.hostname = "ds-ctl" + dsctlj.vm.network "private_network", ip: "192.168.50.20" + dsctlj.vm.provider :virtualbox do |vb| + vb.memory = 4096 + end + dsctlj.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "devstack-control.pp" + puppet.facter = { + "devstack_branch" => "master" + } + end + end + + config.vm.define "ds-c1-juno" do |dsc1j| + dsc1j.vm.box = "saucy64" + dsc1j.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box" + dsc1j.vm.hostname = "ds-c1" + dsc1j.vm.network "private_network", ip: "192.168.50.21" + dsc1j.vm.provider :virtualbox do |vb| + vb.memory = 4096 + end + dsc1j.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "devstack-compute.pp" + puppet.facter = { + "devstack_branch" => "master" + } + end + end + + config.vm.define "ds-c2-juno" do |dsc2j| + dsc2j.vm.box = "saucy64" + dsc2j.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box" + dsc2j.vm.hostname = "ds-c2" + dsc2j.vm.network "private_network", ip: "192.168.50.22" + dsc2j.vm.provider :virtualbox do |vb| + vb.memory = 4096 + end + dsc2j.vm.provision "puppet" do |puppet| + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.working_directory = "/vagrant/puppet" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "devstack-compute.pp" + puppet.facter = { + "devstack_branch" => "master" + } + end + end + +end diff --git a/test/tools/odl-openstack-integration/puppet/hiera.yaml b/test/tools/odl-openstack-integration/puppet/hiera.yaml new file mode 100644 index 0000000000..a93e1d9fdc --- /dev/null +++ b/test/tools/odl-openstack-integration/puppet/hiera.yaml @@ -0,0 +1,10 @@ +--- +:backends: + - yaml + - json +:yaml: + :datadir: /vagrant/puppet/hieradata +:json: + :datadir: /vagrant/puppet/hieradata +:hierarchy: + - hosts diff --git a/test/tools/odl-openstack-integration/puppet/hieradata/hosts.json b/test/tools/odl-openstack-integration/puppet/hieradata/hosts.json new file mode 100644 index 0000000000..d5feaae440 --- /dev/null +++ b/test/tools/odl-openstack-integration/puppet/hieradata/hosts.json @@ -0,0 +1,20 @@ +{ + "hosts": { + "opendaylight": { + "name": "opendaylight", + "ipaddress": "192.168.50.1" + }, + "ds-ctl": { + "name": "ds-ctl", + "ipaddress": "192.168.50.20" + }, + "ds-c1": { + "name": "ds-c1", + "ipaddress": "192.168.50.21" + }, + "ds-c2": { + "name": "ds-c2", + "ipaddress": "192.168.50.22" + } + } +} diff --git a/test/tools/odl-openstack-integration/puppet/manifests/base.pp b/test/tools/odl-openstack-integration/puppet/manifests/base.pp new file mode 100644 index 0000000000..6622d16737 --- /dev/null +++ b/test/tools/odl-openstack-integration/puppet/manifests/base.pp @@ -0,0 +1,12 @@ +package {'git': + ensure => 'installed' +} + +$hosts = hiera('hosts') + +file { '/etc/hosts': + ensure => file, + owner => 'root', + group => 'root', + content => template('/vagrant/puppet/templates/hosts.erb') +} diff --git a/test/tools/odl-openstack-integration/puppet/manifests/devstack-compute.pp b/test/tools/odl-openstack-integration/puppet/manifests/devstack-compute.pp new file mode 100644 index 0000000000..b97f7e85b1 --- /dev/null +++ b/test/tools/odl-openstack-integration/puppet/manifests/devstack-compute.pp @@ -0,0 +1,17 @@ +vcsrepo { '/home/vagrant/devstack': + ensure => present, + provider => git, + user => 'vagrant', + source => 'https://github.com/openstack-dev/devstack.git', + revision => $devstack_branch, + 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/puppet/templates/compute.local.conf.erb') +} diff --git a/test/tools/odl-openstack-integration/puppet/manifests/devstack-control.pp b/test/tools/odl-openstack-integration/puppet/manifests/devstack-control.pp new file mode 100644 index 0000000000..9bc7f3ad00 --- /dev/null +++ b/test/tools/odl-openstack-integration/puppet/manifests/devstack-control.pp @@ -0,0 +1,17 @@ +vcsrepo { '/home/vagrant/devstack': + ensure => present, + provider => git, + user => 'vagrant', + source => 'https://github.com/openstack-dev/devstack.git', + revision => $devstack_branch, + 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/puppet/templates/control.local.conf.erb') +} diff --git a/test/tools/odl-openstack-integration/puppet/scripts/bootstrap.sh b/test/tools/odl-openstack-integration/puppet/scripts/bootstrap.sh new file mode 100644 index 0000000000..6895b7df6d --- /dev/null +++ b/test/tools/odl-openstack-integration/puppet/scripts/bootstrap.sh @@ -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/test/tools/odl-openstack-integration/puppet/templates/compute.local.conf.erb b/test/tools/odl-openstack-integration/puppet/templates/compute.local.conf.erb new file mode 100644 index 0000000000..f99956ef39 --- /dev/null +++ b/test/tools/odl-openstack-integration/puppet/templates/compute.local.conf.erb @@ -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[@hostname]['ipaddress'] %> +HOST_NAME=<%= @hosts[@hostname]['name'] %> +SERVICE_HOST=<%= @hosts['ds-ctl']['name'] %> +SERVICE_HOST_NAME=<%= @hosts['ds-ctl']['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/test/tools/odl-openstack-integration/puppet/templates/control.local.conf.erb b/test/tools/odl-openstack-integration/puppet/templates/control.local.conf.erb new file mode 100644 index 0000000000..50f2cb716d --- /dev/null +++ b/test/tools/odl-openstack-integration/puppet/templates/control.local.conf.erb @@ -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['ds-ctl']['ipaddress'] %> +HOST_NAME=<%= @hosts['ds-ctl']['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/test/tools/odl-openstack-integration/puppet/templates/hosts.erb b/test/tools/odl-openstack-integration/puppet/templates/hosts.erb new file mode 100644 index 0000000000..c23f40fca2 --- /dev/null +++ b/test/tools/odl-openstack-integration/puppet/templates/hosts.erb @@ -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 %> -- 2.36.6