Vagrant with OpenStack

Dec 18, 2014 00:00 · 326 words · 2 minute read howto vagrant

If you want to use Vagrant with OpenStack, you need to prepare Vagrant with installing the vagrant-openstack-plugin. I had some problems installing it directly through vagrant plugin install. I had to clone it from Github and install it manually.

One time configuration

Install OpenStack plugin in Vagrant

cd /tmp
git clone
cd vagrant-openstack-plugin
gem build vagrant-openstack-plugin.gemspec
vagrant plugin install vagrant-openstack-plugin-*.gem

Add a dummy box to Vagrant thats needed by the plugin.

vagrant box add dummy

Download OpenStack RC file

  • Log into OpenStack
  • Download OpenStack API RC file
    • Go to Project -> Compute -> Access & Security -> API Access
    • Down RC file by hitting Download OpenStack RC File
    • Put $ in your ~/ or somewhere you prefer

Configure a Vagrant VM


This is a default generic Vagrant file which starts a m1.tiny flavor image of Ubuntu Utopic. It requires that you already have added your ssh key to OpenStack. Please add your ssh key with the name $USER_ssh_key.

require 'vagrant-openstack-plugin'

Vagrant.configure("2") do |config| = "dummy"
  config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/"

  # Make sure the private key from the key pair is provided
  config.ssh.private_key_path = "~/.ssh/id_rsa"

  config.vm.provider :openstack do |os|
    os.username     = "#{ENV['OS_USERNAME']}"
    os.api_key      = "#{ENV['OS_PASSWORD']}"
    os.flavor       = /m1.tiny/
    os.image        = "Ubuntu CI utopic 2014-09-18"
    os.endpoint     = "#{ENV['OS_AUTH_URL']}/tokens"
    os.keypair_name = "#{ENV['OS_USERNAME']}_ssh_key"
    os.ssh_username = "ubuntu"

    # The tenant have two networks, so need to specify at least one = "vagrant"
    os.floating_ip        = :auto
    os.floating_ip_pool   = "public"

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

  config.vm.provision "shell", inline: <<-SCRIPT
    # Set your country code here to get a local repositroy
    grep -q /etc/apt/sources.list || sed -i~ "$" /etc/apt/sources.list
    apt-get update

  config.vm.define "myvm" do |v|

Create your custom bootstrap file.


# Your aditional bootstrap here...

Running Vagrant

Remember to source your OpenStack RC file before you run Vagrant up. You need to do that in each shell windows you are going to run Vagrant in.

source ~/$
vagrant up