Skip to content

Instantly share code, notes, and snippets.

@rmyers
Last active February 28, 2017 18:28
Show Gist options
  • Save rmyers/88e8ad65e5d4e7b80547418343d5d38b to your computer and use it in GitHub Desktop.
Save rmyers/88e8ad65e5d4e7b80547418343d5d38b to your computer and use it in GitHub Desktop.
OR Devtools Vagrant
$script = <<SCRIPT
##!/usr/bin/env bash
#
# GLOBAL VARIABLES
#
YELLOW='\033[1;33m'
PURPLE='\033[1;35m'
GREEN='\033[1;32m'
RED='\033[1;31m'
NC='\033[0m'
DEVTOOLS=/workspace/devtools
COMPOSE_VERSION=1.11.2
COMPOSE=/usr/local/bin/docker-compose
function f_info() {
echo -e "${YELLOW}[ INFO ]${NC} ${@}"
}
function f_error() {
echo -e "${RED}[ ERROR ]${NC} ${@}"
}
function f_success() {
echo -e "${PURPLE}[ OK ]${NC} ${@}"
}
function check_for_fail() {
if [ $1 == 0 ] ; then
f_success $2
return
else
f_error $2
exit 1
fi
}
function install_pkg() {
local _PACKAGE=$@
f_info "Install package: ${_PACKAGE}"
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install -o Dpkg::Options::=--force-confold -y -qq ${_PACKAGE}
check_for_fail $? "Install ${_PACKAGE}"
}
f_info "Installing Objectrocket Devtools"
apt-get update -qq
check_for_fail $? "apt-get update"
install_pkg python-pip
install_pkg python-dev
install_pkg curl
f_info "Updating docker-compose"
rm -f ${COMPOSE}
curl -sSL "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o ${COMPOSE}
check_for_fail $? "Downloading docker-compose"
chmod +x ${COMPOSE}
${COMPOSE} --version
f_info "Running pip updates"
python $DEVTOOLS/modules/pipconf.py
f_info "Installing requirements"
pip install -r $DEVTOOLS/requirements.txt
f_info "DEVTOOLS VM Has been provisioned"
f_info "Login: vagrant ssh and run:"
f_info "-> cd /workspace/devtools"
f_info "-> ./dev install"
f_info "-> docker-compose up -d -f docker-compose.mesosphere.yml"
cat <<MOTD > /etc/motd
Welcome to Objectrocket Devtools:
cd ${DEVTOOLS}
python dev install
docker-compose up -d -f docker-compose.mesosphere.yml
MOTD
SCRIPT
Vagrant.configure("2") do |config|
WORKSPACE_SOURCE_DIR = ENV['WORKSPACE_SOURCE_DIR'] || ".."
WORKSPACE_SYNC_DIR = ENV['WORKSPACE_SYNC_DIR'] || "/workspace"
GO_SOURCE_DIR = ENV['GOPATH']
GO_SYNC_DIR = ENV['GO_SYNC_DIR'] || "/go"
config.vm.box = "bento/ubuntu-16.04"
MEMORY = ENV['VM_MEMORY'] || 4086
config.vm.provider :virtualbox do |vb, override|
vb.customize ["modifyvm", :id, "--memory", MEMORY.to_s]
end
# All the hosts mount the workspace to bootstrap ansible
config.vm.synced_folder WORKSPACE_SOURCE_DIR, WORKSPACE_SYNC_DIR
config.vm.synced_folder GO_SOURCE_DIR, GO_SYNC_DIR
config.vm.define "service" do |service|
service.vm.network "private_network", ip: "172.20.20.10"
service.vm.hostname = "objectrocket"
service.vm.provision "docker"
service.vm.provision "shell", inline: $script
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment