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 https://github.com/cloudbau/vagrant-openstack-plugin
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 https://github.com/cloudbau/vagrant-openstack-plugin/raw/master/dummy.box
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
$USER-openrc.shin your~/or somewhere you prefer
- Go to
Configure a Vagrant VM
Vagrantfile
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|
config.vm.box = "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
os.network = "vagrant"
os.floating_ip = :auto
os.floating_ip_pool = "public"
end
config.vm.provision "shell", path: "bootstrap.sh"
config.vm.provision "shell", inline: <<-SCRIPT
# Set your country code here to get a local repositroy
CN="no"
grep -q repo.met.no /etc/apt/sources.list || sed -i~ "s#nova.clouds.archive.ubuntu.com#$CN.archive.ubuntu.com#g" /etc/apt/sources.list
apt-get update
SCRIPT
config.vm.define "myvm" do |v|
end
end
bootstrap.sh
Create your custom bootstrap file.
#!/bin/bash
# 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 ~/$USER-openrc.sh
vagrant up