From 0a8a5336d4f16c66c115738c038ca03b1099d351 Mon Sep 17 00:00:00 2001 From: Jaume Devesa Date: Tue, 15 Dec 2015 17:09:00 +0100 Subject: [PATCH] Allow rpm-based machines This patch modifies the vagrant provision scripts slightly to allow to deploy CentOS/RedHat machines via VAGRANT_KURYR_VM_BOX. Change-Id: I8860e6fbb4c2929bfcd67aefbff208f7d13be8f8 --- contrib/vagrant/README.md | 7 ++++++- contrib/vagrant/Vagrantfile | 3 +++ contrib/vagrant/devstack.sh | 33 ++++++++++++++++++++++++++------- contrib/vagrant/vagrant.sh | 2 +- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/contrib/vagrant/README.md b/contrib/vagrant/README.md index dc7c1af2..6f9bd5df 100644 --- a/contrib/vagrant/README.md +++ b/contrib/vagrant/README.md @@ -37,6 +37,11 @@ You can set the following environment variables before running `vagrant up` to m the definition of the Virtual Machine spawned: * **VAGRANT\_KURYR\_VM\_BOX**: To change the Vagrant Box used. Should be available in - [atlas](atlas.hashicorp.com) + [atlas](atlas.hashicorp.com). + + export VAGRANT_KURYR_VM_BOX=centos/7 + + Could be an example of a rpm-based option. + * **VAGRANT\_KURYR\_VM\_MEMORY**: To modify the RAM of the VM. Defaulted to: 4096 * **VAGRANT\_KURYR\_VM\_CPU**: To modify the cpus of the VM. Defaulted to: 2 diff --git a/contrib/vagrant/Vagrantfile b/contrib/vagrant/Vagrantfile index a3d67960..d8fc4405 100644 --- a/contrib/vagrant/Vagrantfile +++ b/contrib/vagrant/Vagrantfile @@ -30,6 +30,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end config.vm.synced_folder '../../devstack/', '/devstack' + # For CentOS machines it needs to be specified + config.vm.synced_folder '.', '/vagrant' + config.vm.provision :shell, :path => 'vagrant.sh' if Vagrant.has_plugin?('vagrant-cachier') diff --git a/contrib/vagrant/devstack.sh b/contrib/vagrant/devstack.sh index abf489f9..32119e93 100755 --- a/contrib/vagrant/devstack.sh +++ b/contrib/vagrant/devstack.sh @@ -1,19 +1,38 @@ -#!/bin/sh +#!/bin/bash + +set -e BASHPATH=$(dirname "$0"\") -echo "run script from $BASHPATH" +echo "Run script from $BASHPATH" -# update system -export DEBIAN_FRONTEND noninteractive -sudo apt-get update -sudo apt-get install -qqy git +# 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" ] +if [[ ! -d "$DEVSTACK" ]] then echo "Download devstack into $DEVSTACK" diff --git a/contrib/vagrant/vagrant.sh b/contrib/vagrant/vagrant.sh index 3f744e62..b0c2b0bd 100755 --- a/contrib/vagrant/vagrant.sh +++ b/contrib/vagrant/vagrant.sh @@ -4,7 +4,7 @@ export OS_USER=vagrant export OS_HOST_IP=172.68.5.10 # run script -sh /vagrant/devstack.sh +bash /vagrant/devstack.sh #set environment variables for kuryr su "$OS_USER" -c "echo 'source /vagrant/config/kuryr_rc' >> ~/.bashrc"