vagrant: Add a Vagrant setup for Astara

Add a Vagrant configuration for Astara. This makes it easy for someone
to pull the openstack/astara repository and get up and running with an
Astara setup quickly.

Change-Id: I600328c2a53a8d4aff5bf39a96aaa5b79ef99464
Signed-off-by: Kyle Mestery <mestery@mestery.com>
This commit is contained in:
Kyle Mestery 2016-05-20 15:37:01 -05:00
parent 6a934060f0
commit e82baba8d0
6 changed files with 205 additions and 0 deletions

4
.gitignore vendored
View File

@ -47,3 +47,7 @@ astara/test/functional/test.conf.sample
#macos hidden files #macos hidden files
.DS_Store .DS_Store
._.DS_Store ._.DS_Store
# Vagrant
vagrant/.vagrant
vagrant/user_local.conf

View File

@ -0,0 +1,27 @@
#
# Sample DevStack local.conf.
#
# This sample file is intended to be used for your typical DevStack environment
# that's running all of OpenStack on a single host. This can also be used as
# the first host of a multi-host test environment.
#
# No changes to this sample configuration are required for this to work.
#
[[local|localrc]]
enable_plugin astara https://github.com/openstack/astara
enable_service q-svc q-agt astara
disable_service n-net
# Build the Astara appliance
#BUILD_ASTARA_APPLIANCE_IMAGE=True
#ASTARA_APPLIANCE_REPO=http://github.com/openstack/astara-appliance.git
#ASTARA_APPLIANCE_BRANCH=master
HOST_IP=127.0.0.1
LOGFILE=/opt/stack/logs/devstack.log
DATABASE_PASSWORD=secret
RABBIT_PASSWORD=secret
SERVICE_TOKEN=secret
SERVICE_PASSWORD=secret
ADMIN_PASSWORD=secret

60
vagrant/README.md Normal file
View File

@ -0,0 +1,60 @@
vagrant-devstack-astara
=======================
Getting started
---------------
A Vagrant based astara.
Steps to try vagrant image:
1. Install Vagrant on your local machine. Install one of the current
providers supported: VirtualBox, Libvirt or Vagrant
2. Git clone the astara repository.
3. Run `cd vagrant`
4. Run `vagrant up`
It will take from 10 to 60 minutes, depending on your internet speed.
Vagrant-cachier can speed up the process [1].
5. `vagrant ssh`
You will get a VM with everything running.
You will get vm shell with keystone and neutron already running.
At this point you should have astara running inside of the Vagrant VM.
[1] http://fgrehm.viewdocs.io/vagrant-cachier/
Vagrant Options available
-------------------------
You can set the following environment variables before running `vagrant up` to modify
the definition of the Virtual Machine spawned:
* **VAGRANT\_ASTARA\_VM\_BOX**: To change the Vagrant Box used. Should be available in
[atlas](http://atlas.hashicorp.com).
export VAGRANT_ASTARA_VM_BOX=centos/7
Could be an example of a rpm-based option.
* **VAGRANT\_ASTARA\_VM\_MEMORY**: To modify the RAM of the VM. Defaulted to: 4096
* **VAGRANT\_ASTARA\_VM\_CPU**: To modify the cpus of the VM. Defaulted to: 2
* **VAGRANT\_ASTARA\_RUN\_DEVSTACK**: Whether `vagrant up` should run devstack to
have an environment ready to use. Set it to 'false' if you want to edit
`local.conf` before run ./stack.sh manually in the VM. Defaulted to: true.
See below for additional options for editing local.conf.
Additional devstack configuration
---------------------------------
To add additional configuration to local.conf before the VM is provisioned, you can
create a file called "user_local.conf" in the vagrant directory of astara. This file
will be appended to the "local.conf" created during the Vagrant provisioning.
For example, to use OVN as the Neutron plugin with Astara, you can create a
"user_local.conf" with the following configuration:
enable_plugin networking-ovn http://git.openstack.org/openstack/networking-ovn
enable_service ovn-northd
enable_service ovn-controller
disable_service q-agt
disable_service q-l3

47
vagrant/Vagrantfile vendored Normal file
View File

@ -0,0 +1,47 @@
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
VM_MEMORY = ENV.fetch('VAGRANT_ASTARA_VM_MEMORY', 6144)
VM_CPUS = ENV.fetch('VAGRANT_ASTARA_VM_CPUS', 2)
RUN_DEVSTACK = ENV.fetch('VAGRANT_ASTARA_RUN_DEVSTACK', 'true')
config.vm.hostname = 'devstack'
config.vm.provider 'virtualbox' do |v, override|
override.vm.box = ENV.fetch('VAGRANT_ASTARA_VM_BOX', 'ubuntu/trusty64')
v.memory = VM_MEMORY
v.cpus = VM_CPUS
end
config.vm.provider 'parallels' do |v, override|
override.vm.box = ENV.fetch('VAGRANT_ASTARA_VM_BOX', 'boxcutter/ubuntu1404')
v.memory = VM_MEMORY
v.cpus = VM_CPUS
v.customize ['set', :id, '--nested-virt', 'on']
end
config.vm.provider 'libvirt' do |v, override|
override.vm.box = ENV.fetch('VAGRANT_ASTARA_VM_BOX', 'celebdor/trusty64')
v.memory = VM_MEMORY
v.cpus = VM_CPUS
v.nested = true
v.graphics_type = 'spice'
v.video_type = 'qxl'
end
config.vm.synced_folder '../devstack/', '/devstack'
# For CentOS machines it needs to be specified
config.vm.synced_folder '.', '/vagrant'
config.vm.provision :shell do |s|
s.path = 'vagrant.sh'
s.args = RUN_DEVSTACK
end
if Vagrant.has_plugin?('vagrant-cachier')
config.cache.scope = :box
end
config.vm.network :forwarded_port, guest: 80, host_ip: "127.0.0.1", host: 8080
end

60
vagrant/devstack.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/bash
set -e
BASHPATH=$(dirname "$0"\")
RUN_DEVSTACK="$1"
echo "Run script from $BASHPATH"
# Copied shamelessly from Devstack
function GetOSVersion {
if [[ -x $(which lsb_release 2>/dev/null) ]]; then
os_FAMILY='Debian'
elif [[ -r /etc/redhat-release ]]; then
os_FAMILY='RedHat'
else
echo "Unsupported distribution!"
exit 1;
fi
}
GetOSVersion
if [[ "$os_FAMILY" == "Debian" ]]; then
export DEBIAN_FRONTEND noninteractive
sudo apt-get update
sudo apt-get install -qqy git
elif [[ "$os_FAMILY" == "RedHat" ]]; then
sudo yum install -y -d 0 -e 0 git
fi
# determine checkout folder
PWD=$(su "$OS_USER" -c "cd && pwd")
DEVSTACK=$PWD/devstack
# check if devstack is already there
if [[ ! -d "$DEVSTACK" ]]
then
echo "Download devstack into $DEVSTACK"
# clone devstack
su "$OS_USER" -c "cd && git clone -b master https://github.com/openstack-dev/devstack.git $DEVSTACK"
echo "Copy configuration"
# copy local.conf.sample settings (source: astara/devstack/local.conf.sample)
cp /devstack/local.conf.sample $DEVSTACK/local.conf
# If local settings are present, append them
if [ -f "/vagrant/user_local.conf" ]; then
cat /vagrant/user_local.conf >> $DEVSTACK/local.conf
fi
chown "$OS_USER":"$OS_USER" "$DEVSTACK"/local.conf
fi
if $RUN_DEVSTACK; then
echo "Start Devstack"
su "$OS_USER" -c "cd $DEVSTACK && ./stack.sh"
else
echo "Virtual Machine ready. You can run devstack by executing '/home/vagrant/devstack/stack.sh'"
fi

7
vagrant/vagrant.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
export OS_USER=vagrant
export OS_HOST_IP=172.68.5.10
# run script
bash /vagrant/devstack.sh "$1"