Merge "Reworked setup_env.sh to support Debian & Darwin/OSX"
This commit is contained in:
commit
b022c4d1e4
22
Vagrantfile
vendored
Normal file
22
Vagrantfile
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# -*- mode: ruby -*-
|
||||||
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
|
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||||
|
# configures the configuration version (we support older styles for
|
||||||
|
# backwards compatibility). Please don't change it unless you know what
|
||||||
|
# you're doing.
|
||||||
|
Vagrant.configure(2) do |config|
|
||||||
|
|
||||||
|
# vagrant box to sanity check setup_env.sh
|
||||||
|
config.vm.define :trusty64, autostart: false do |trusty|
|
||||||
|
trusty.vm.box = "ubuntu/trusty64"
|
||||||
|
trusty.vm.provision "shell", :inline => "apt-get update -y"
|
||||||
|
trusty.vm.provision "shell", :inline => "cd /vagrant ; ./setup_env.sh"
|
||||||
|
end
|
||||||
|
|
||||||
|
# vagrant box to sanity check setup_env.sh
|
||||||
|
config.vm.define :centos7, autostart: false do |centos|
|
||||||
|
centos.vm.box = "centos/7"
|
||||||
|
centos.vm.provision "shell", :inline => "cd /home/vagrant/sync ; ./setup_env.sh"
|
||||||
|
end
|
||||||
|
end
|
38
setup_env.sh
38
setup_env.sh
@ -1,21 +1,45 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Install python pip & virtualenv packages & then create
|
||||||
|
# a python virtualenv & install the infra-ansible dependencies in it
|
||||||
|
|
||||||
# Install virtualenv package if not installed
|
# check platform prerequisites
|
||||||
if [ ! -f /usr/bin/pip ]; then
|
case $(uname) in
|
||||||
sudo -E apt-get install python-pip
|
Linux)
|
||||||
|
# check if the apt-get executable is available
|
||||||
|
if hash apt-get 2>/dev/null; then
|
||||||
|
# check for & install the various packages
|
||||||
|
hash pip 2>/dev/null || { sudo -E apt-get install -y python-pip; }
|
||||||
|
[[ -z "$(dpkg -l python-dev | grep '^ii python-dev')" ]] && sudo -E apt-get install -y python-dev
|
||||||
|
hash virtualenv 2>/dev/null || { sudo pip install virtualenv; }
|
||||||
|
elif hash yum 2>/dev/null; then
|
||||||
|
# on RHEL/CentOS, pip is installed during the virtualenv setup
|
||||||
|
hash virtualenv 2>/dev/null || { sudo -E yum install -y python-virtualenv python-devel gcc gcc-c++; }
|
||||||
|
hash wget 2>/dev/null || { sudo -E yum install -y wget; }
|
||||||
|
else
|
||||||
|
echo "ERROR: Zoinks, I only know about Debian and RHEL"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create infra-ansible virtual environment
|
;;
|
||||||
pip install virtualenv
|
Darwin)
|
||||||
|
hash pip 2>/dev/null || { echo "ERROR: pip isn't installed, please rectify this!" ; exit 1; }
|
||||||
|
hash virtualenv 2>/dev/null || { sudo pip install virtualenv; }
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
# Create a fresh infra-ansible virtual environment
|
||||||
|
[[ -e venv ]] && rm -rf venv
|
||||||
virtualenv venv
|
virtualenv venv
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
# Create inventory folder
|
# Create inventory folder
|
||||||
if [ ! -d inventory ]; then
|
if [[ ! -d inventory ]]; then
|
||||||
mkdir inventory
|
mkdir inventory
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Ansible openstack inventory
|
# Install Ansible openstack inventory
|
||||||
/usr/bin/wget -N https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/openstack.py -O inventory/openstack.py
|
wget https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/openstack.py -O inventory/openstack.py
|
||||||
chmod +x inventory/openstack.py
|
chmod +x inventory/openstack.py
|
||||||
|
Loading…
Reference in New Issue
Block a user