Devstack with Vagrant, Quick and Dirty

Devstack with Vagrant

You can test the openstack with vagrant using devstack. We will assume that you have Vagrant, virtualbox and git installed on your computer, and configure virtualBox as the default provider. Following tutorial was created to make your life easier, especially when implementing devstack to build an openstack development environment for demo or training to end users.

Step 1: Create a new vagrant box

Execute the following commands to create a new Vagrant box:

C:\pseudo\Vagrant>mkdir devstack
C:\pseudo\Vagrant>cd devstack
C:\pseudo\Vagrant\devstack>vagrant init

There is now a Vagrantfile in the current directory

Step 2: Modify Vagrantfile

We use bento/ubuntu-16.04 boxes as base images.

Vagrant.configure("2") do |config| = "bento/ubuntu-16.04"
  config.vm.hostname = 'devstack'

# We also expose the port to the devstack interface, this will create port mapping, and set the network interface IP Address "forwarded_port", guest: 80, host: 80 "forwarded_port", guest: 5000, host: 5000 "forwarded_port", guest: 9696, host: 9696 "forwarded_port", guest: 8774, host: 8774 "forwarded_port", guest: 35357, host: 35357 "private_network", ip: ""

# virtualbox provisioning, e.g. Memory and CPU

config.vm.provider :virtualbox do |v|
    v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    v.customize ['modifyvm', :id, '--natnet1', '']
    v.customize ["modifyvm", :id, "--memory", 4096]
    v.customize ["modifyvm", :id, "--cpus", 2]

# To make it easier, we set shell script to provision the devstack environment once the VM is running, so no need manual stacking.

config.vm.provision "shell", path: ""

Here’s the as above explanation.


echo "****** Provisioning virtual machine...******"
echo "****** Install Git...******"
sudo apt-get install git

echo "****** Devstack deployment...******"
sudo useradd -s /bin/bash -d /opt/stack -m stack
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack
su - stack -c "cd /opt/stack && git clone"
su - stack -c "cat > /opt/stack/devstack/local.conf << END
HOST_IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')

echo "****** started...******"
su - stack -c "cd /opt/stack/devstack && ./"

Step 3: Start Devstack

Start devstack by executing:

C:\pseudo\Vagrant>vagrant up

Now open the horizon thru the IP Address with credentials as mentioned earlier, for this case is