Create a complete OpenStack test installation with devstack, Vagrant and VirtualBox on a MacBook Pro

10 minute read

If you go in for virtualization, continuous integration (CI) and DevOps, sooner or later the cloud technology OpenStack pops up. Unfortunately, it’s not easy to get up and running with OpenStack.

In order to install a complete OpenStack infrastructure you already should have some experience with OpenStack. On the other hand, a running OpenStack environment is almost essential in order to learn OpenStack. A typical chicken/egg problem….

A good starting point for OpenStack is DEVSTACK, a script that is able to set up a complete OpenStack installation on different flavors of linux.

In combination with VirualBox and Vagrant I was able to set up a OpenStack playgound on my MacBook Pro.

That’s how it works, shown in a manual step by step way, so you know what happens1:

System requirements

VirualBox and Vagrant are installed on the MacBook.

Create the VM for the installation

First we need a base system. Since we currently run Ubuntu 12.04 LTS (Precise) on our production systems, i chose this flavor.

Important: This virtual machine should have quite some memory. We will start some VMs in this VM after all. To access the OpenStack VM it is handy to have a private IP address. With this address we can access the services in the VM without having to do all the port forwarding.

So let’s create a project directory and put this Vagrantfile into it:

<%= render_code(“Vagrantfile”, “ruby”) %>

The VM got 2 GB of memory and at most 75% of my Mac cpu.

After typing

    $ vagrant up

it takes some time to bring our base system up.

Update the VM and install required base packages

Now we have to set up our fresh linux to an up-to-date state.

Connect to the new machine with

    $ vagrant ssh

and upgrade the system packages with

    sudo su
    echo deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main >> /etc/apt/sources.list.d/grizzly.list
    apt-get install python-software-properties software-properties-common python-keyring -y
    apt-get update
    apt-get install ubuntu-cloud-keyring -y
    apt-get update
    apt-get upgrade
    apt-get dist-upgrade
    apt-get install git -y

Hint: The duplicate update is neccessary since the keys for the ubuntu cloud packages are not contained in the base image, but we do need the cloud packages. But to install the ubuntu-cloud-keyring, we do need an updated system.

Furthermore we need git to pull the devstack repository.

Since there was probably a kernel upgrade, we reboot our system and log in again.

Create the devstack user

The devstack script should run in a non-root user account which has sudo rights. We could use the default vagrant user for this, but i prefer to have a seperate user for this. Therefore we crate a new user stack.

    sudo su
    adduser stack
    echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

Now log in as user stack and download devstack:

    su - stack
    git clone git://github.com/openstack-dev/devstack.git
    cd devstack

Install the cloud

Finally we start the devstack script:

    ./stack.sh

At this point it’s a good time to get some coffee or even have your lunch break, since the download and installation of the complete OpenStack installation takes about half an hour.

After completion you see something like:

    Horizon is now available at http://10.0.2.15/
    Keystone is serving at http://10.0.2.15:5000/v2.0/
    Examples on using novaclient command line is in exercise.sh
    The default users are: admin and demo
    The password: d19e329a91e25271a369
    This is your host ip: 10.0.2.15
    stack.sh completed in 1426 seconds.
    stack@precise64:~/devstack
    $

Voilá, we do have a complete working cloud on a MacBook Pro :-). The only gotcha is that stack.sh took the wrong IP address (it should be 10.12.14.16, configured in the Vagrantfile).

What have we got so far?

Since i did not install any hypervisor, the script choose “QEMU”, a software based virtualization by emulation. This is quite good enough For learning purposes. For production environments you would of course use something like KVM or XEN.

The installed image is CirrOS, which is good for testing purposes as well. The OpenStack web site contains several other VM images.

The access to the OpenStack web interface you have to use the IP address 10.12.14.16 (specified in the Vagrantfile) instead of the one prompted by the script.

Unforuntately, some links of the OpenStack-UI include the wrong IP address, e. g. the console of the VMs. I do not have a workaround for this issue right now. Probably it would be a good idea to map ports 80, 5000 and 6000 (console) to localhost in the Vagrantfile.

Next steps

I plan to automate this setup even further (probably with puppet) to be able to set up my playground by a single command.

The next step would then be to include KVM and/or XEN within my cloud VM.

And finally, build a bare metal cloud server…


Footnotes
  1. I created a GitHub project for this HowTo, which eventually automates most of the steps out of the box using Vagrant and Puppet.